globals accros modules

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Jan 11 06:15:31 CET 2007


At Thursday 11/1/2007 01:11, alf wrote:

>How can I have global globals without cyclical import?

You can't. Globals are module globals. You need to qualify *which* 
module `a` belongs to.

>--------------------
>amodule.py:
>def f():
>      global a
>      print a
>--------------------
>main.py:
>import amodule
>a=1
>amodule.f()

Change a=1 to amodule.a=1
If you find yourself doing tricks with the module globals, think 
about redesigning your application.


-- 
Gabriel Genellina
Softlab SRL 


	

	
		
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 




More information about the Python-list mailing list