[IPython-user] dir format

librik at panix.com librik at panix.com
Fri Dec 1 20:28:35 CST 2006


Tony Mannucci <Tony.Mannucci at jpl.nasa.gov> wrote:
> 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?

This isn't really the fault of dir, but the fault of the simplistic
Python "pretty printing" function.  When it prints a list, it puts
one element on each line!  (Try entering "range(100)" to see what I
mean.)  IPython uses "pretty printing" for anything it prints as the
return value of an evaluation, which is a bit of a pain in this case.

Luckily, IPython does not use pretty printing for the "print" command,
because that's part of the Python implementation itself.  So if you
use "print dir(sys)" you'll get the old default non-pretty printed
output.

- David Librik
librik at panix.com


More information about the IPython-user mailing list