Created
July 24, 2015 17:22
-
-
Save shofetim/3d337657e4bfc239838e to your computer and use it in GitHub Desktop.
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
def deprecated(func): | |
''' | |
This is a decorator which can be used to mark functions | |
as deprecated. It will result in a warning being emmitted | |
when the function is used. | |
''' | |
def newFunc(*args, **kwargs): | |
warnings.warn('Call to deprecated function %s.' % func.__name__, | |
category=DeprecationWarning) | |
return func(*args, **kwargs) | |
newFunc.__name__ = func.__name__ | |
newFunc.__doc__ = func.__doc__ | |
newFunc.__dict__.update(func.__dict__) | |
return newFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment