Created
June 30, 2010 14:05
-
-
Save lvidarte/458694 to your computer and use it in GitHub Desktop.
deprecated decorator
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
import warnings | |
def deprecated(func): | |
def new_func(*args, **kwargs): | |
warnings.warn('This function is deprecated', DeprecationWarning, 2) | |
return func(*args, **kwargs) | |
return new_func | |
@deprecated | |
def sum(a, b): | |
return a + b | |
r = sum(1, 2) | |
print r |
Author
lvidarte
commented
Jun 30, 2010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment