Listing of declared variables and functions

Bill Mill bill.mill at gmail.com
Mon May 9 13:16:00 EDT 2005


On 9 May 2005 09:58:19 -0700, ohms377 <frankie.y.liu at gmail.com> 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).
> 

>>> x = 12
>>> z = 13
>>> import re
>>> locals()
{'__builtins__': <module '__builtin__' (built-in)>, 're': <module 're' from '/us
r/lib/python2.4/re.pyc'>, 'x': 12, '__name__': '__main__', 'z': 13, '__doc__': N
one}
>>> locals().keys()
['__builtins__', 're', 'x', '__name__', 'z', '__doc__']
>>> globals()
{'__builtins__': <module '__builtin__' (built-in)>, 're': <module 're' from '/us
r/lib/python2.4/re.pyc'>, 'x': 12, '__name__': '__main__', 'z': 13, '__doc__': N
one}

Peace
Bill Mill
bill.mill at gmail.com



More information about the Python-list mailing list