Created
November 27, 2018 02:56
-
-
Save binki/6839968fb11affdf9eb36bd6e3d4b81f to your computer and use it in GitHub Desktop.
Python function binding
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
#!/usr/bin/env python | |
def my_func(x): | |
print(x) | |
def build_my_func_call(x): | |
def f(): | |
my_func(x) | |
return f | |
funcs = [ | |
build_my_func_call('a'), | |
build_my_func_call('b'), | |
] | |
for f in funcs: | |
f() | |
funcs.reverse() | |
for f in funcs: | |
f() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment