Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个以编程方式写入附加功能的模块。 IE:
def fun1(): # function written on 27.02.13 ... def fun2(): # function written on 28.02.13 ...
我想在运行时向模块本身和这些函数添加文档字符串,而不修改文件。
这可以通过另一个脚本来完成吗?
您可以,只需__doc__向模块添加一个属性:
__doc__
import foo foo.__doc__ = '''My docstring for this module'''