Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Python reflection magic
import inspect
def call(fun, **myArgs):
names, _, _, values = inspect.getargspec(builder)
defaults = zip(names, values)
valuesToCallWith = dict(defaults + myArgs.items())
return fun(**valuesToCallWith)
def builder(a = 0, b = 2, c = 3):
return a + b + c
print call(builder, a = 3) # prints 8
print call(builder, b = 9, c = 1) # prints 10
print call(builder, c = 11) # prints 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.