Created
June 16, 2014 11:31
-
-
Save technige/4ac84784ac82ac04bb6e 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(message): | |
""" Decorator for deprecating functions and methods. | |
:: | |
@deprecated("'foo' has been deprecated in favour of 'bar'") | |
def foo(x): | |
pass | |
""" | |
def f__(f): | |
def f_(*args, **kwargs): | |
warnings.warn(message, category=DeprecationWarning, stacklevel=2) | |
return f(*args, **kwargs) | |
f_.__name__ = f.__name__ | |
f_.__doc__ = f.__doc__ | |
f_.__dict__.update(f.__dict__) | |
return f_ | |
return f__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment