将文档字符串添加到namedtuples?
是否可以通过简单的方式将文档字符串添加到namedtuple? 我试过了 from collections import namedtuple Point = namedtuple("Point", ["x", "y"]) """ A point in 2D space """ # Yet another test """ A(nother) point in 2D space """ Point2 = namedtuple("Point2", ["x", "y"]) print Point.__doc__ # -> "Point(x, y)" print Point2.__doc__ # -> "Point2(x, y)" 但这并不能解决问题。是否可以通过其他方式进行?