xxxxxxxxxx
# in the opposite exaple
# it makes an error
# unbound var
if True:
me = "hi"
else:
me = 0
# thats bec py thinks that this var might be undefiend
# u might repair that simply by defining the var befor the block of code
me = None
if True:
me = "hi"
else:
me = 0
xxxxxxxxxx
>>> foo = None
>>> def bar():
global foo
if False:
foo = 'spam'
print foo
>>> bar()
None
# Python needs to know in the beginning of the function if you plan on using the local or the
# global version of the variable. Remember that you can't declare variables in python. You can
# only bind them. Read more in the naming and binding section of the python reference documentation
# https://docs.python.org/2.3/ref/naming.html