Global variable oddness w/short code example

Aahz aahz at pythoncraft.com
Mon Jun 2 19:56:04 EDT 2003


In article <pan.2003.06.02.23.42.23.521303 at apeiron.net>,
Geoffrey Mainland  <mainland at apeiron.net> wrote:
>
>I've run into some global variable oddness with Python 2.2.2 (running
>under FreeBSD). As I understand it, global variables are global only
>within a module. However, as the code below demonstrates, when module A
>creates a global and then calls a function in module B which accesses the
>new global (via the construct A.theGlobal), the global is not seen. Can
>anyone explain the following oddness?

Not in detail, but the fundamental problem is that you're actually
dealing with three modules: A, B, and __main__

Recursive imports are a Bad Idea.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra




More information about the Python-list mailing list