473,739 Members | 9,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2711
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************ *************** ***********@pyt hon.org>,
Fernando Perez <fp********@gma il.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10535
by: benyang22 | last post by:
I have been a long time Matlab user. I Python, I miss Matlab's whos command. So I have written a little utility whos.py, which can be downloaded here: http://beluga.eos.ubc.ca/~tang/softwares/python/ Here is the doc string: # Before using whos, do:
4
1295
by: rusttree | last post by:
I've been tasked with a project to take a large program coded in c++ and a generate a list of the names of every variable and where they are declared. Are there programs out there that will do something like that? If this is a snippet of code: void someFunction(){ int foo; char bob;
2
5207
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb file, and what would I do to access it? (I am using VB.NET for my code) Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
2
1715
by: robin.bruce | last post by:
Hi guys, I just tried to give advice to a colleague who has a problem program in C, and I was interested to hear the thoughts of this forum on the subject. I've been an occasional programmer in C for about a year now, so by no means an expert, so it would be good to know if I'm leading my colleague down the wrong path.
62
4127
by: Juuso Hukkanen | last post by:
I am looking for a wish list of things which should be removed from the C (C99) - due to feature's bad security track record <OT>or Multithreading unsafety. I need this list for a project intending to build another (easiest & most powerful) programming language, which has a two page definition document stating: "... includes C programming language (C99), except its famous "avoid-using-this-functions". </OT> If you would not want to...
3
12559
by: Tyno Gendo | last post by:
I don't really need to do this, but I was wondering. Is there some way of obtaining a list of all the variables that have been declared in a PHP script ? Ie. for globals you have $_GLOBAL, is there something that would let you know the name of all variables that have been declared? Ta.
9
1672
by: Ramashish Baranwal | last post by:
Hi, I want to get a module's contents (classes, functions and variables) in the order in which they are declared. Using dir(module) therefore doesn't work for me as it returns a list in alphabetical order. As an example- # mymodule.py class B: pass class A: pass
0
1441
by: Gary Herron | last post by:
Jacob Davis wrote: Yuck, YUCK, YUCK! You are breaking *so* many good-programming-practices, I hardly know where to start. First off: A python global is not what you think. There are *no* program wide globals. There are only module wide globals. Also, the "global isglobal" is absolutely meaningless as anything declared there is a (module level) global by definition.
17
8376
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline the function if possible" (because if the compiler has the function definition available at an instantiation point, it will estimate whether to inline it or not, and do so if it estimates it would be beneficial, completely regardless of whether...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.