[Tutor] Viewing __doc__ strings
Walter Moreira
wall@adinet.com.uy
Fri, 8 Jun 2001 12:53:21 -0300
On Fri, Jun 08, 2001 at 03:41:03PM +0100, Allan Crooks wrote:
> Hi,
>
> Is there anyway to make Python display __doc__ strings without all the "\n" characters? I know I could manually split it and then rejoin it, but surely there's an easier way?
>
> I'm using Python 2.1 on WinNT 4, if that's of any use.
Use the pydoc module which is included in 2.1. For example:
>>> def f(x):
... """A dummy function.
... It returns x.
... """
... return x
...
>>> f.__doc__
'A dummy function.\n\tIt returns x.\n\t'
>>>
>>> from pydoc import help
>>> help(f)
Help on function f in module __main__:
f(x)
A dummy function.
It returns x.
pydoc is really cool!!
Regards:
Walter
--
--------------
Walter Moreira <> Centro de Matematica <> Universidad de la Republica
email: walterm@cmat.edu.uy <> HomePage: http://www.cmat.edu.uy/~walterm
+-----------------------------------------------------
/OD\_ | LEARNING, n. The kind of ignorance distinguishing
O o . |_o_o_) | the studious.
| -- Ambrose Bierce. Devil's Dictionary
--+--