[Chicago] Using globals across files

Ian Bicking ianb at colorstudy.com
Tue Mar 28 23:31:11 CEST 2006


Michael Tobis wrote:
> If you aren't creating new references on the fly, and you don't mind
> being suspected
> of being unpythonic:
> 
> 
>>cat myglob.py
> 
> 
> # myglob.py
> 
> a = 42
> 
> 
>>python
> 
> 
>>>>from myglob import *

That's probably exactly what you *don't* want to do, because you are 
actually copying "a" into your module, i.e., it is equivalent to:

import myglob
a = myglob.a

So changes to myglob.a will not be reflected in the local a variable. 
It works for constants, but not for counters or anything like that.



-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Chicago mailing list