Hey all again.
It appears to me that functions can reference variables outside of their scope but cannot set them. Is this correct? Am I understanding this right. I also included the gloals usage,. I KNOW they are bad - ju-ju and will avoid.
I know how to get around this but just want to be clear.
My example program:
import foo
# beginning of functions
# this one works because I look at the variable but dont modify it
def do_something_working:
if flag_to_do_something:
print "I did it"
# this one does not work because I modify the var
def do_something_not_working:
if flag_to_do_something:
print "I did it"
flag_to_do_something = 0
# this one works but if I do this god kills a kitten
def do_something_using_globals_working_bad_ju_ju:
global flag_to_do_something
if flag_to_do_something:
print "I did it"
flag_to_do_something = 0
# end of functions
flag_to_do_something = 1
do_something_working()
do_something_not_working()
do_something_using_globals_working_bad_ju_ju()