Created
September 20, 2015 22:08
-
-
Save manuphatak/e74f1f5197b8947af933 to your computer and use it in GitHub Desktop.
Revisions
-
manuphatak created this gist
Sep 20, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ from functools import wraps def defaults(method='__init__', **default_args): """Class decorator. Overrides method default arguments.""" def decorate(cls): func = getattr(cls, method) @wraps(func) def wrapper(self, *args, **kwargs): default_args.update(kwargs) return func(self, *args, **default_args) setattr(cls, method, wrapper) return cls return decorate