"intermodule-global" variables

Eddy Ilg eddy at netido.de
Sat Jun 5 15:32:03 EDT 2004


Hi, 


I am having a problem with an application I am writing: 

I have 2 scripts called 'conf' and 'build'. Both define 
a variable named 'root' and import a module named 'helper'.

In the helper module I want to access the root variable, that is 
_either_ in conf _or_ build. How can I do this?  
I just want the root variable to be global for all modules.
(I don't want to put root in helper, since that would make no sense at
all)


I also tried this: 

---- helper.py 
a=5

def printa():
	global a
	print a
----

>> from helper import * 
>> a
5
>> a=6
>> a
6
>> printa()
5


Why does this not work? Why are there suddenly two variables a? One 
for helper.py (stays 5) and a global one (became 6)? This is a bit
irritating. Didn't find it in any documentation


Thanks

Eddy 




More information about the Python-list mailing list