Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Listing of declared variables and functions

Reply
Thread Tools

Listing of declared variables and functions

 
 
ohms377
Guest
Posts: n/a
 
      05-09-2005
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

 
Reply With Quote
 
 
 
 
Bill Mill
Guest
Posts: n/a
 
      05-09-2005
On 9 May 2005 09:58:19 -0700, ohms377 <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Fernando Perez
Guest
Posts: n/a
 
      05-10-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

 
Reply With Quote
 
Cameron Laird
Guest
Posts: n/a
 
      05-11-2005
In article <(E-Mail Removed)>,
Fernando Perez <(E-Mail Removed)> 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.

.
.
.
Fernando's IPython is indeed a great thing, one I often recommend.
I think you might want to know, though, that local and global heaps
are readily available even without it:
Python 2.3.5 (#2, Mar 26 2005, 17:32:32)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3
>>> locals()

{'__builtins__': <module '__builtin__' (built-in)>, '__name__':
'__main__', '__doc__': None, 'a': 3}
>>> globals()

{'__builtins__': <module '__builtin__' (built-in)>, '__name__':
'__main__', '__doc__': None, 'a': 3}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
declared or not declared ? JohnZing ASP .Net 3 02-05-2006 08:38 PM
Variables not declared and "undefined" property values David R Javascript 1 11-07-2005 01:03 AM
Implicitly declared/defined member functions and inheritance lovecreatesbeauty C++ 7 05-12-2005 02:10 AM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
How to access data or functions of the derived class if it was declared as the base class? Titan C++ 1 06-30-2003 03:04 PM



Advertisments