470,601 Members | 1,534 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,601 developers. It's quick & easy.

Listing of declared variables and functions

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).

Thanks,

-frankie

Jul 19 '05 #1
3 2622
On 9 May 2005 09:58:19 -0700, ohms377 <fr***********@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
Jul 19 '05 #2
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

Jul 19 '05 #3
In article <ma**************************************@python.o rg>,
Fernando Perez <fp********@gmail.com> wrote:
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.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by benyang22 | last post: by
4 posts views Thread by rusttree | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
2 posts views Thread by robin.bruce | last post: by
62 posts views Thread by Juuso Hukkanen | last post: by
3 posts views Thread by Tyno Gendo | last post: by
9 posts views Thread by Ramashish Baranwal | last post: by
reply views Thread by Gary Herron | last post: by
17 posts views Thread by Juha Nieminen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.