Raymond Hettinger added the comment: FWIW, here's a proposed new classmethod that makes it possible to easily customize the field docstrings but without cluttering the API of the factory function:
@classmethod def _set_docstrings(cls, **docstrings): '''Customize the field docstrings >>> Point = namedtuple('Point', ['x', 'y']) >>> Point._set_docstrings(x = 'abscissa', y = 'ordinate') ''' for fieldname, docstring in docstrings.items(): if fieldname not in cls._fields: raise ValueError('Fieldname %r does not exist' % fieldname) new_property = _property(getattr(cls, fieldname), doc=docstring) setattr(cls, fieldname, new_property) Note, nothing is needed for the main docstring since it is already writeable: Point.__doc__ = '2-D Coordinate' ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16669> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com