Created
July 14, 2013 22:14
-
-
Save weswigham/5996328 to your computer and use it in GitHub Desktop.
Scope in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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