Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python unbound variable

>>> 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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #unbound #variable
ADD COMMENT
Topic
Name
1+6 =