Created
June 10, 2016 15:58
-
-
Save sils/d66af494eaa630ae2683a6e2db0f1b14 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
import logging | |
from functools import wraps | |
def bear_deprecated(old_name, new_name): | |
""" | |
Emits a deprecation warning when this decorator is executed. | |
>>> @module_deprecated("a", "b") | |
... def a(): | |
... return 2 | |
WARNING:root:'a' is deprecated. Use 'b' instead! | |
>>> a() | |
2 | |
:param old_name: | |
:param new_name: | |
:return: | |
""" | |
logging.warning("'{}' is deprecated. Use '{}' instead!".format(old_name, | |
new_name)) | |
return wraps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shouldn't the warning be emitted when the function is called?