Skip to content

Instantly share code, notes, and snippets.

@nickylimjj
Last active March 11, 2019 23:45
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 nickylimjj/97e95c9ed41086b01b4f2d0e2e36aa9e to your computer and use it in GitHub Desktop.
Save nickylimjj/97e95c9ed41086b01b4f2d0e2e36aa9e to your computer and use it in GitHub Desktop.
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'
@nickylimjj
Copy link
Author

same behavior in javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment