Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
from inspect import getargspec
def filter_dict(d, fltr):
return dict( (x, d[x]) for x in fltr if x in d )
def apply_some(f, *args, **kwargs):
fspec = getargspec(f)
return f(*args, **kwargs) if fspec.keywords else f( *args, **filter_dict(kwargs, fspec.args) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment