Is it possible to add a documentation string to a namedtuple in an easy manner?
I tried
from collections import namedtuple
Point = namedtuple(\"Poin
No need to use a wrapper class as suggested by the accepted answer. Simply literally add a docstring:
from collections import namedtuple
Point = namedtuple("Point", ["x", "y"])
Point.__doc__="A point in 2D space"
This results in: (example using ipython3):
In [1]: Point?
Type: type
String Form:
Docstring: A point in 2D space
In [2]:
Voilà!