Skip to content

Instantly share code, notes, and snippets.

@esamattis
Created March 26, 2010 00:11
Show Gist options
  • Select an option

  • Save esamattis/344297 to your computer and use it in GitHub Desktop.

Select an option

Save esamattis/344297 to your computer and use it in GitHub Desktop.
def foo(value):
def closure():
print value
# Works without this
value = "Override"
return value
return closure
print foo("something")()
Traceback (most recent call last):
File "/home/epeli/ohjelmointi/Subuser/subssh/poista.py", line 15, in <module>
print foo("something")()
File "/home/epeli/ohjelmointi/Subuser/subssh/poista.py", line 4, in closure
print value
UnboundLocalError: local variable 'value' referenced before assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment