有没有可能以一种简单的方式向 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)"
但是这并不能解决问题。有没有可能用其他的方法来解决呢?