In <579a15bf-83c0-4228-9079-bbaac1222...@o13g2000vbl.googlegroups.com> Marius 
Gedminas <mged...@gmail.com> writes:

>On Sep 4, 9:29=A0pm, kj <no.em...@please.post> wrote:
>> The only solution I can come up with is to define a "dummy module",
>> say _config.py, which contains only upper-case variables representing
>> these global switches, and is imported by all the other modules in
>> the application with the line "from _config import *". =A0During the
>> early stages of the run, the script inspects the command-line flags,
>> and if it finds a --continuing flag, it sets the variable
>> _config.CONTINUATION_MODE to True. =A0(The last point implies that
>> these variables are not strictly speaking read-only, since they
>> most be set at the beginning of the run. =A0But after this initial
>> setting, they should remain read-only.)

>Be very very careful about "from _config import *".  If you import
>a module that, in turn, imports _config this way, before you set
>the initial values, that module will already have made its own copies
>of all the variables and thus will not see the correct values.

Good point.  That's another reason for going for something like
Nick's solution earlier in this thread.

Thanks,

kynn
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to