Created
July 19, 2012 11:55
-
-
Save hayd/3143331 to your computer and use it in GitHub Desktop.
grabbing f's environment from within g
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 f(): | |
a = 2 | |
b = 1 | |
def g(): | |
#a = 3 | |
b = 2 | |
c = 1 | |
print dict(globals(), **locals()) #prints a=1, but we want a=2 (from f) | |
g() | |
a = 1 | |
f() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment