whos -- a function listing objects

Fernando Perez fperez.net at gmail.com
Fri Jun 17 13:59:15 EDT 2005


benyang22 at yahoo.com wrote:

> I have been a long time Matlab user. I Python, I miss Matlab's whos
> command.

<plug> you might want to look at ipython.  whos, and a bit more come for free:

planck[~]> ipython -pylab
Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
Type "copyright", "credits" or "license" for more information.

IPython 0.6.16_cvs -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: def foo(): pass
   ...:

In [2]: a=rand(128,128)

In [3]: x=3.14

In [4]: import code

In [5]: whos
Variable   Type        Data/Info
--------------------------------
a          array       128x128: 16384 elems, type `d`, 131072 bytes (128 kb)
code       module      <module 'code' from '/usr<...>/lib/python2.3/code.pyc'>
foo        function    <function foo at 0x41203cdc>
x          float       3.14

In [6]: whos array
Variable   Type     Data/Info
-----------------------------
a          array    128x128: 16384 elems, type `d`, 131072 bytes (128 kb)

In [7]: whos function
Variable   Type        Data/Info
--------------------------------
foo        function    <function foo at 0x41203cdc>



Cheers,

f




More information about the Python-list mailing list