[Numpy-discussion] ndarray newbie question
Pierre GM
pgmdevlist at gmail.com
Fri Jan 5 03:56:56 CST 2007
belinda thom wrote:
> > Some context: the type of introspection I'm often wishing I could do
> > in a single, easy command usually has to do w/getting to know the
> > software better.
For generic introspection in Python, dir and .__doc__ are very useful.
The ? trick works in ipython and prints the __doc__.
> When I try the latter recommendation above w/numpy arrays, I get:
...
> Type: NoneType
> Base Class: <type 'NoneType'>
> String Form: None
> Namespace: Interactive
> Docstring:
> <no docstring>
I agree that this one is not really informative. A
>>> a.__class__.__doc__?
provides a docstring interestingly truncated under ipython, but nothing
useful either.
However, you may want to consider the combination:
>>> for k in dir(a):
>>> try:
>>> print "\n",k, getattr(a,k).__doc__
>>> except AttributeError:
>>> pass
But I'm a bit confused: what are you really trying to achieve by querying the
methods of a numpy array ? The wiki page
http://www.scipy.org/Numpy_Example_List_With_Doc
is quite educational, and provides many examples of usage you won't find in
the docstrings.
More information about the Numpy-discussion
mailing list