Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

Roel Schroeven roel at roelschroeven.net
Wed Mar 6 10:39:09 EST 2024


Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list:
> If you import the contents of that file into the python interpreter, [...]

What exactly to you mean by "import the contents of that file into the 
python interpreter"? Other people have put your code in a script, 
executed it, and saw it working as expected. I pasted in IPython, and 
likewise saw it working as expected, and the same with IDLE. It seems to 
me you must be doing something different from us; maybe the way you 
execute that code might be the key to this whole confusion.

-- 
"Il semble que la perfection soit atteinte non quand il n'y a plus rien à
ajouter, mais quand il n'y a plus rien à retrancher."
"Perfectie is niet bereikt als er niets meer toe te voegen is, maar als er
niets meer weg te nemen is."
         -- Antoine de Saint-Exupéry



More information about the Python-list mailing list