std lib suggestion: Publish docstring unindent part of inspect.getdoc() as a function

Ville Vainio vvainio at tp.spt.fi
Mon Jun 3 07:48:57 EDT 2002


I often use triple-quoted strings to describe various "content", and
would like to get the results in an undindented form. inspect.getdoc()
does this for the docstrings, but I would like to see the same
algorithm as a seperate function. I would assume that it isn't too
rare to want this. Aligning those strings to the left column directly
in the source looks horrible.

Such a feature apparently doesn't exist at the moment, since
inspect.getdoc does it by hand. If if was a function (say,
string.unindent), getdoc could just be

return string.unindent(object.__doc__)

(+ handling for nonexistent __doc__, of course)

It is of course trivial to copy-paste the implementation from
inspect.getdoc(), but at least I would use such a feature all the
time. string module already has capitalize(), so my request probably
isn't way out of line ;-).

-- Ville



More information about the Python-list mailing list