Skip to content

Instantly share code, notes, and snippets.

@daeken
Created December 16, 2009 02:11
Show Gist options
  • Save daeken/257524 to your computer and use it in GitHub Desktop.
Save daeken/257524 to your computer and use it in GitHub Desktop.
def sanitizeArgs(func):
if func.func_code.co_flags & 8: # Has **var
return func # Can't know what arguments it takes
accepts = func.func_code.co_varnames[:func.func_code.co_argcount]
def sub(*args, **kwargs):
return func(*args, **dict((key, val) for key, val in kwargs.items() if key in accepts))
return sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment