Blurbs ansible coffeescript django dvcs erlang es6 hg javascript json lua mercurial peewee postgresql python scope sql sqlalchemy yaml

Globals and locals code pythonscope

item = 'spam'

def p():
    print item # <<<
    for item in ['foo', 'bar']:
        print item

p()

# >>> UnboundLocalError: local variable 'item' referenced before assignment

# variable global to a scope that you reassign within that scope
# is marked local to that scope by the compiler.

http://stackoverflow.com/questions/404534/python-globals-locals-and-unboundlocalerror