Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created June 30, 2010 13:43
Show Gist options
  • Save lvidarte/458664 to your computer and use it in GitHub Desktop.
Save lvidarte/458664 to your computer and use it in GitHub Desktop.
decorator with argument
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