Created
June 30, 2010 13:43
-
-
Save lvidarte/458664 to your computer and use it in GitHub Desktop.
decorator with argument
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 change_doc(docstring): | |
def decorator(func): | |
func.__doc__ = docstring | |
return func | |
return decorator | |
@change_doc('new docstring 1') | |
def foo(): | |
'''original docstring''' | |
pass | |
print foo.__doc__ | |
print foo | |
bar = change_doc('new docstring 2')(foo) | |
print bar.__doc__ | |
print bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment