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

James Mills prologic at shortcircuit.net.au
Mon Mar 14 03:57:02 CET 2011


On Mon, Mar 14, 2011 at 12:41 PM, Tim Lesher <tlesher at gmail.com> wrote:
> [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?

Works for me. Python 3.2 on 32bit Linux.

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"


More information about the Python-Dev mailing list