[Python-Dev] __doc__ string of builtin types
holger krekel
pyth@devel.trillke.net
Thu, 16 May 2002 12:35:59 +0200
Thomas Heller wrote:
> From: "Patrick K. O'Brien" <pobrien@orbtech.com>
> > [Thomas Heller]
> > >
> > > (I've filed a slightly confused bug report 550290.)
> > >
> > > "spam".__doc__ is the same as str.__doc__,
> > > it describes what the str(...) would do. Same for
> > > 42 . __doc__, and certainly many other objects.
> > > While normally I don't care about the doc-string of
> > > these objects, the output of pydoc looks strange:
> >
> > I agree. I see the same thing with the namespace viewer in PyCrust under
> > Python 2.2 and it is less than ideal, imho.
> >
> I've uploaded a patch to http://www.python.org/sf/550290, currently
> for stringobject.c only, which keeps the current doc-string
> for the 'str' type/function, but returns None as the doc-string
> of str instances. The same could (and should) be done for
> int, float, and maybe other builtin types as well. The patch
> can easily be changed to return an actual doc-string.
as a workaround i have in the past used the check
getattr(type(obj),'__doc__','')==getattr(obj,'__doc__','')
to determine if an object has 'real' documentation.
only doesn't work for the type-object because type(type)==type.
holger