Last active
March 11, 2019 23:45
-
-
Save nickylimjj/97e95c9ed41086b01b4f2d0e2e36aa9e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 b (): | |
print( myvar ) | |
def a (): | |
myvar = 'a' | |
b() | |
myvar = 'outer' | |
a() # will print 'outer' because it looks down the scope chain, NOT execution / stack trace | |
def c (): | |
def d (): | |
print( myvar ) | |
myvar = 'c' | |
d() | |
myvar = 'outer' | |
c() # prints 'c' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
same behavior in javascript