whos and clear (as in matlab) functionality

Fernando Perez fperez528 at yahoo.com
Thu Mar 20 12:22:28 EST 2003


Thomas Knudsen wrote:

> I'm a python newbie, currently in the process of moving
> parts of my work from Matlab to python + Numeric.
> 
> When using python interactively, I  often need something
> like the Matlab "whos" command.
> 
> In Matlab "whos" returns a list of all variables:
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> a = 4;
>>> b = [1 2 3; 4 5 6];
>>> whos
> Name      Size                   Bytes  Class
> 
> a         1x1                        8  double array
> b         2x3                       48  double array
> 
> Grand total is 7 elements using 56 bytes
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> is there any way of doing something similar in python?

Would this work for you?

In [1]: a=4;

In [2]: b=array([[1,2,3],[4,5,6]]);

In [3]: whos
Variable   Type    Data/Length
------------------------------
a          int      4
b          array    [[1 2 3]
 [4 5 6]]


Take a look at http://ipython.scipy.org/

Cheers,

f




More information about the Python-list mailing list