how to pass globals across modules (wxPython)

Fredrik Lundh fredrik at pythonware.com
Tue Dec 21 11:02:18 EST 2004


Jorge Luiz Godoy Filho wrote:

>> An even better approach might be to find a way to avoid
>> having to access the main window through a global, but
>> I'll have to leave this up to you, as it may depend on
>> your program structure.
>
> This might be a problem also to share a database connection, where one needs
> to pass the open and authenticated connection to several specialized
> modules.
>
> Maybe a module where you can access that should be a better option...

or a single "application context class" instance, which is passed to various
parts of the system as necessary.

making subsystems dependent on a module can hinder reuse; making them
dependent on (parts of) the interface of an application context object makes
them a lot easier to reuse.

</F> 






More information about the Python-list mailing list