Skip to content

Instantly share code, notes, and snippets.

@weswigham
Created July 14, 2013 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weswigham/5996328 to your computer and use it in GitHub Desktop.
Save weswigham/5996328 to your computer and use it in GitHub Desktop.
Scope in python
def SomeFunc():
x = 3
def InnerFunc():
x = 22
InnerFunc()
return x
#Now tell me, what does SomeFunc return? It returns 3. That's not what we wanted to do, was it? How do you even change this code to make the x in the inner function reference the one in the scope above it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment