[IPython-user] dir format

Fernando Perez fperez.net at gmail.com
Fri Dec 1 13:11:21 CST 2006


On 12/1/06, Tony Mannucci <Tony.Mannucci at jpl.nasa.gov> wrote:
> I have just started using ipython. I am very happy with it so far.
> It's an excellent piece of work.
>
> A significant pet-peeve is the overriding of the python dir(). I use
> dir to see the attributes and classes in a module. For example:
>
> import numpy as N
>
> dir(N)
>
> With python, I get a wide listing that can fit all the attributes on
> one screen. With ipython, each attribute is on a separate line and
> list scrolls off the screen. I cannot access all attributes (my
> screen buffer is not that large). Is there a variable setting to
> change the behavior of dir? Can I get the old dir back?

dir(N) returns a list, and IPython uses 'pretty printing' by default.
You can toggle this with

%Pprint

or permanently set  it in your ~/.ipython/ipythonrc file.

But you may want to use

N.a<TAB>

for inspecting an object, most of us seem to find TAB completion a
faster mechanism for introspection than dir().  Additionally, the ?
facilities have wildcard search:

In [3]: N.*cos*?
N.arccos
N.arccosh
N.cos
N.cosh

In [4]: N.cos*?
N.cos
N.cosh


Cheers,

f


More information about the IPython-user mailing list