Passing Global Variables between imported modules

Sean sean at activeprime.com
Tue Aug 5 10:39:27 EDT 2003


Thanks for the help guys.  Passing the variable as a class parameter
(or even function parameter) is not really a possibility due to the
structure of the actual program code.  The real world problem is that
I'm defining a global variable for a base application path for my
program, which changes depending on whether the program is being run
as a script, an compiled exe, and if there are preconfigured settings
in the windows registry and/or a config file.  This was previously
being done in the global space of the "main" application script.  The
class that needed this info was about 5 or six steps down the import
tree.

I think my solution is going to involve taking all the logic for
finding the base path out of the main app script and putting it in
it's own module.  That way anything that needs to see that variable
can just import that module and not have to worry about strange import
loops.

-Sean Levatino




More information about the Python-list mailing list