how to pass globals across modules (wxPython)

Fredrik Lundh fredrik at pythonware.com
Tue Dec 21 13:33:51 EST 2004


Jorge Luiz Godoy Filho wrote:

> > or a single "application context class" instance, which is passed to
> > various parts of the system as necessary.
>
> Wouldn't that cause a chicken & egg problem?  How, then, would one pass such
> an instance across modules?

well, in my applications, subsystems usually consists of one or more classes, or at least
one or more functions.  code that needs the global context usually gets the content either
as a constructor argument, or as an argument to individual methods/functions.

if you build a system by execfile'ing subcomponents (or importing them just to run their
code, rather than use what they define), using this approach is harder.  but that's not a
very good way to build systems, so I'm not sure that matters...

</F> 






More information about the Python-list mailing list