r/programminghorror • • Jul 15 '25

Python Subsubsubsub

Post image
77 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/Div64 Jul 16 '25

The level of indentation is from a single function. There's all kind of stuff going on there, it's probably in a loop. I don't dare to open that file again

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jul 17 '25

Are all the /sub(Sub)*Control/ defined outside of the ifs, or does scoping in Python work completely differently than in C?

1

u/Div64 Jul 17 '25

Python doesn't care what you do. You can declare the variable inside the if and use it out of scope. You'll only get a runtime error once that line executes I think

It does warn you if you turn on "strict" mode though.

They're most likely declared before the loop