Module function can't see globals after import.
Ron_Adam
radam2 at tampabay.rr.com
Mon Mar 28 21:09:43 EST 2005
On Mon, 28 Mar 2005 20:46:32 +0300, Christos "TZOTZIOY" Georgiou
<tzot at sil-tec.gr> wrote:
>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:
Actually I avoid them where ever and when ever possible. ;)
This is more of an attempt to help find and prevent problems of that
sort. I've started to put together a took kit package of sorts for
finding and preventing problems. It needs to look at the name spaces
to work correctly.
>import __main__
>
>and access the main modules globals (eg 'x') as:
>
>__main__.x
Thanks, 'That worked fine.! :)
More information about the Python-list
mailing list