docstring show under decorator
http://stackoverflow测试数据/questions/3865254/about-python-doc-docstring/3865321#3865321
functools. wraps ( wrapped [ , assigned ] [ , updated ] ) ?
This is a convenience function for invoking partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated) as a function decorator when defining a wrapper function. For example:
>>> from functools import wraps >>> def my_decorator ( f ): ... @wraps ( f ) ... def wrapper ( * args , ** kwds ): ... print 'Calling decorated function' ... return f ( * args , ** kwds ) ... return wrapper ... >>> @my_decorator ... def example (): ... """Docstring""" ... print 'Called example function' ... >>> example () Calling decorated function Called example function >>> example . __name__ 'example' >>> example . __doc__ 'Docstring'
Without the use of this decorator factory, the name of the example function would have been 'wrapper' , and the docstring of the original example() would have been lost.
查看更多关于docstring show under decorator的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did43821