想一想
help(yourmodule)在交互式口译员的提示下做的某人-他们 想
知道什么?(其他提取和显示信息的方法在信息量方面大致相同
help)。因此,如果您有
x.py:
"""This module does blah blah."""class Blah(object): """This class does blah blah."""
然后:
>>> import x; help(x)
显示:
Help on module x:NAME x - This module does blah blah.FILE /tmp/x.pyCLASSES __builtin__.object Blah class Blah(__builtin__.object) | This class does blah blah. | | Data and other attributes defined here: | | __dict__ = <dictproxy object> | dictionary for instance variables (if defined) | | __weakref__ = <attribute '__weakref__' of 'Blah' objects> | list of weak references to the object (if defined)
如您所见,这些组件的文档字符串中已经包含了有关类的详细信息(以及函数,尽管这里没有显示)。该模块自己的文档字符串应该非常简要地描述它们(如果有的话),而应该专注于该模块作为一个整体可以为您做什么的简要概述,理想情况下是带有一些经过文档测试的示例(就像函数和类在理想情况下应该在文档中经过文档测试的示例一样)他们的文档字符串)。
我看不到诸如作者姓名和版权/许可证之类的元数据如何帮助该模块的用户-宁可添加注释,因为它可以帮助某人考虑是否重用或修改该模块。



