Module function can't see globals after import.

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Mon Mar 28 12:46:32 EST 2005


On Mon, 28 Mar 2005 17:19:42 GMT, rumours say that Ron_Adam
<radam2 at tampabay.rr.com> might have written:

>Is there a way to tell the imported function printx to use mymain's
>globals instead of it's own copy without passing it as an argument?

No, but if you insist on working with globals for some reason of your
own, in the module you can:

import __main__

and access the main modules globals (eg 'x') as:

__main__.x
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...



More information about the Python-list mailing list