Some examples:
<pre>
>>> @author("John")
... @author("Paul")
... def test():
... "Test function"
...
>>> help(test)
Help on function test in module __main__:
test() Author: John Author: Paul Test function </pre>
1 2 3 4 5 6 7 8 | def author(name):
def setauthor(func):
author = "Author: %s" % name
if func.__doc__:
author += "\n" + func.__doc__
func.__doc__ = author
return func
return setauthor
|
Tags: shortcuts
This python is not simple enough. Python should be simple. This python code is not simple enough.
I add the above comment to "Decorator for appending author info to the function docstring (Python 2.4)", but why it's here?