Created
November 15, 2010 20:45
-
-
Save joseanpg/700913 to your computer and use it in GitHub Desktop.
Sharing
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(x): | |
def g(y): | |
def h1(z): | |
nonlocal x,y | |
x = z | |
y = 2*z | |
print(locals()) | |
def h2(z): | |
print(locals()) | |
return z+y+x | |
return [h1,h2] | |
return g | |
# >>> par = f(5)(10) | |
# >>> par[1](2) | |
# {'y': 10, 'x': 5, 'z': 2} | |
# 17 | |
# >>> par[0](7) | |
# {'y': 14, 'x': 7, 'z': 7} | |
# >>> par[1](8) | |
# {'y': 14, 'x': 7, 'z': 8} | |
# 29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment