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

Raymond Hettinger raymond.hettinger at gmail.com
Tue Mar 15 19:40:51 CET 2011


One of simplest and least invasive ways to get help()
to show the underscore methods and attributes is to 
make pydoc aware of named tuples by checking for the 
presence of _fields. 

* That leaves the named tuple code as simple as possible
(which is important because the self-documenting code
is exposed to the user through the verbose option).

* It supports the _1, _2 attributes created by the rename
option, and it works with user supplied underscore methods
and attributes in a subclass.

* It doesn't exaggerate the importance of help issue
which AFAICT hasn't ever been noticed or cared about
since the introduction of named tuples a few years ago
or since the publication of its recipe in years prior to that.


Raymond


P.S.  There are other ways like creating an abstract
base class to identify a class as having underscored
names that aren't private (like _from_iterable in the
ABC for sets), but this seems to me like trying to 
kill a mosquito with a cannon.  The underlying issue
is so minor that it rules out invasive or heavy-weight
efforts.


More information about the Python-Dev mailing list