Accessing one's main script's global from imported libraries

marshall marshall at
Wed Feb 26 03:32:39 CET 2003

czrpb <nanotech at> wrote in message news:<mailman.1046111768.26279.python-list at>...
> All:
> Say I have with the global taste.
> Say in I import eggs.
> Say I want eggs to access's taste global.
> How might I do this?
> thanks!! Quentin

As you will no doubt read, you are not _supposed_ to do this.  You are
_supposed_ to be passing parameters from the objects or functions in to the objects or functions in  However, I have
believe the best practice to acheive what you want is to have a
separate file (e.g. and have all other files import
that.  I could very well be wrong about that but that is what works
for me (newbie disclaimer).

I think the more general question is: "What is the best way to split a
large program up into several modules and still let them all have
access to application global data?"

What I have been doing is creating an Application instance which has
all of the global data (like maxscreensize, datapath, etc.) as
attributes.  Then I pass this App instance as a parameter to every
other object that the application creates.  If there is a better way I
would sure like to hear about it.


More information about the Python-list mailing list