Listing of declared variables and functions

Fernando Perez fperez.net at gmail.com
Tue May 10 13:12:10 EDT 2005


ohms377 wrote:

> Dear python users,
> 
> In interactive mode, I was wondering if there is a way to list all
> declared variables and functions (and from global workspace).

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

In [2]: x=1

In [3]: a='hello'

In [4]: import re

In [5]: whos
Variable   Type        Data/Info
--------------------------------
a          str         hello
foo        function    <function foo at 0x403b725c>
re         module      <module 're' from '/usr/lib/python2.3/re.pyc'>
x          int         1

In [6]: whos int
Variable   Type    Data/Info
----------------------------
x          int     1


This is using ipython for the interactive work.

Cheers,

f




More information about the Python-list mailing list