以下示例取自"Dive into python“一书。
class MP3FileInfo(FileInfo):
    "store ID3v1.0 MP3 tags"
    tagDataMap = ...此示例显示了MP3FileInfo文档,但如何向MP3FileInfo添加帮助。tagDataMap
发布于 2009-08-28 15:03:12
将其更改为属性方法。
发布于 2009-08-28 15:04:17
属性文档字符串上的PEP 224被拒绝了(很久以前),所以这对我来说也是一个问题,有时我不知道是选择一个类属性还是实例属性--第二个属性可以有一个文档字符串。
发布于 2009-08-28 15:53:27
如下所示:
class MP3FileInfo(FileInfo):
    """Store ID3v1.0 MP3 tags."""
    @property 
    def tagDataMap(self):
        """This function computes map of tags.
        The amount of work necessary to compute is quite large, therefore
        we memoize the result.
        """
        ...但是请注意,如果属性只有一行描述,那么您确实不应该创建单独的文档字符串。相反,您可以使用
class MP3FileInfo(FileInfo):
    """Store ID3v1.0 MP3 tags.
    Here are the attributes:
        tagDataMap -- contains a map of tags
    """
    tagDataMap = ...https://stackoverflow.com/questions/1347566
复制相似问题