473,398 Members | 2,404 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,398 software developers and data experts.

global namescape of multilevel hierarchy

Hi

I have a script e.g.

import package.module

ID = "55"

package.module.checkID()

now in package.module.checkID function, i wnat to know what is the ID
defiend in the calling scriipt
if I dot globals(), it returns only items in module. is there a way
to get the script level namesapce
thanks

Mar 14 '06 #1
1 1350
Sakcee wrote:
now in package.module.checkID function, i wnat to know what is the ID
defiend in the calling scriipt


It's almost always a really bad idea to kludge scopes like this. If
you need to access a variable from the caller's scope in a module
function, make it an argument to that function. That's what arguments
are for in the first place!

But, if you must, you can use the inspect module:

import inspect
def checkID():
ID = inspect.currentframe().f_back.f_locals['ID']
print ID

--Ben

Mar 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Reimar Bauer | last post by:
Dear all is there an encryption/decryption method available with multilevel passwords? Thanks for any help Reimar Bauer --
5
by: Richard A. DeVenezia | last post by:
Dear Experts: Suppose I have global variables: x1, x2, x3 and I have a function that needs to assign a value to a new global variable x4 something like function foo () { count = 0;
7
by: Bruce Hensley | last post by:
I don't know how to begin on a query (SELECT statement) to find all the tasks assigned to an arbitrary manager (say, staffID='JSmith') and her organization, that is, assigned to all her underlings,...
7
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
2
by: Rythm Music | last post by:
I am trying to get some help on creating a Multilevel Hierarchial Datagrid. What I mean is that the Hierarchial level is unknown. There could be many related records or none. Also there could be...
17
by: Davíð Þórisson | last post by:
now in my web I have some global variables to be used in many different subpages, in the old ASP I simply loaded a variables.asp file into memory using the eval() function. Now I'd like to use XML...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
34
by: Karam Chand | last post by:
Hello I have been working with Access and MySQL for pretty long time. Very simple and able to perform their jobs. I dont need to start a flame anymore :) I have to work with PGSQL for my...
0
by: virendra | last post by:
hi, I am working on crystal report 9 in asp.net. I created multilevel dynamic grouping in CR. if page is load firsttime. and i am giving firstlevel of grouping or whatever it's working fine. but...
0
by: nintesa | last post by:
I'm using Oscommerce, Joomla, Mambo ecc... everyone of these have a good multilevel admin panel. Now I'm developing a new indipendent little application ad I'm wondering if there is a small...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.