473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is namespace available in Python?

440 256MB
Hi,

Is namespace available in Python?.


Thanks
PSB
Mar 2 '07 #1
3 1372
Che M
7
Hi,

Is namespace available in Python?.


Thanks
PSB
Namespaces? If I understand you correctly, yes!
Mar 7 '07 #2
bartonc
6,596 Expert 4TB
Hi,

Is namespace available in Python?.


Thanks
PSB
The .__dict__ attribute of an object stores its namespace. This includes modules. There is a 'builtin' module called __main__ that stores the main namespace.
Use globals() and locals() to see what is in the respective dictionaries.
The inspect library module is used do access regularly needed items. The Pythonic term is introspection and python is quite good at it.
For example, a function can look at the arguments that it was called with in some very cool ways, but this a very advanced topic.
Mar 8 '07 #3
bartonc
6,596 Expert 4TB
The .__dict__ attribute of an object stores its namespace. This includes modules. There is a 'builtin' module called __main__ that stores the main namespace.
Use globals() and locals() to see what is in the respective dictionaries.
The inspect library module is used do access regularly needed items. The Pythonic term is introspection and python is quite good at it.
For example, a function can look at the arguments that it was called with in some very cool ways, but this a very advanced topic.
This is pretty cool:

>>> help(vars)
Help on built-in function vars in module __builtin__:

vars(...)
vars([object]) -> dictionary

Without arguments, equivalent to locals().
With an argument, equivalent to object.__dict__.

>>>
Mar 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Allison | last post by:
Hi everybody I'm very new to python so please forgive any idiotic mistakes: I'm writing a MUD-like text game in python and I want to support dynamic ingame scripting to deal with user commands. I...
0
by: Thomas Weholt | last post by:
This might be slightly off-topic, but I'll ask anyway: I want to import several modules into my cvs-repository, but I want them all to be in the same namespace when they're checked out. For...
8
by: Elaine Jackson | last post by:
I would like to be able to write a function f, which will live in a module M, and will call a function g, such that, when f is imported from M into the interpreter, and invoked there, its...
8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
4
by: jean-marc | last post by:
As an application programmer, I'm not well versed in the material aspects of computing (memory, cpu, bus and all). My understanding of imports in Python is such: the __main__ program is the center...
2
by: Reid Priedhorsky | last post by:
Dear group, I'd have a class defined in one module, which descends from another class defined in a different module. I'd like the superclass to be able to access objects defined in the first...
12
by: reubendb | last post by:
Hello, I am new to Python. I have the following question / problem. I have a visualization software with command-line interface (CLI), which essentially is a Python (v. 2.5) interpreter with...
3
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
1
by: Christof Winter | last post by:
I am trying to use a webservice with SOAPpy: import SOAPpy intact_wsdl = "http://www.ebi.ac.uk/intact/binary-search-ws/binarysearch?wsdl" intact_serv = SOAPpy.WSDL.Proxy(intact_wsdl) The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.