Last active
December 21, 2015 14:18
-
-
Save tlatsas/6318355 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
#!/usr/bin/env python | |
import functools | |
import warnings | |
warnings.simplefilter("once", category=(PendingDeprecationWarning, DeprecationWarning)) | |
def deprecate(msg, klass=PendingDeprecationWarning): | |
def decorator(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
warnings.warn(msg, klass, stacklevel=2) | |
return func(*args, **kwargs) | |
return wrapper | |
return decorator | |
@deprecate("This function will be deprecated in the future") | |
def old_function(a, b): | |
new_function(a, b, 0) | |
def new_function(a, b, c): | |
print(a+b+c) | |
if __name__ == "__main__": | |
old_function(1, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment