[Numpy-discussion] Matlab -> NumPy translation and indexing

Alexander Michael lxander.m at gmail.com
Tue Mar 20 08:27:17 EDT 2007


On 3/20/07, David Koch <ogdude at googlemail.com> wrote:
> And by the way - whenever I do a <function>.__doc__ all newline characters
> are printed as "\n" in the python console ... how do I change that?

The easiest way to access the doc strings is to type help(<function>)
in the python interpreter, or ?<function> in ipython
(<ipython.scipy.org>).

The reason you are seeing the escaped newlines is that by directly
accessing the __doc__ attribute, you are getting the string which the
interpreter is kind enough to display in repr form,  but you are not
explicitly printing it (in str form). Compare:

>>> print repr('hello\nworld')
'hello\nworld'
>>> print str('hello\nworld')
hello
world

So that if you said print <function>.__doc__, you would not see the
escaped newlines.



More information about the NumPy-Discussion mailing list