[Python-Dev] pydoc for named tuples is missing methods

Tim Lesher tlesher at gmail.com
Mon Mar 14 03:41:08 CET 2011


[I mentioned this to Raymond Hettinger after his PyCon talk, and I
promised a bug and hopefully a patch. I don't see an obvious solution,
though, so I'll ask here first.]

Because named tuple prefixes a single underscore to its added method
names (_asdict, _replace, and _make), those methods' docstrings are
omitted from pydoc:

>>> Point=collections.namedtuple('Point', 'x y')
>>> help(Point)
Help on class Point in module __main__:
[output omitted; it excludes _asdict, _replace, and _make]

pydoc's rules for name inclusion are in pydoc.visiblename():

* If the name is in the hidden list, omit it
* If the name looks like a __special_method__, include it
* If the there is an "all" specified, then include it if it appears in all
* Otherwise, include it if it doesn't begin with an underscore

There doesn't seem to be an obvious way to get around these rules for
named tuples... am I overlooking something?

Thanks.
-- 
Tim Lesher <tlesher at gmail.com>


More information about the Python-Dev mailing list