[wingide-users] global imports

Paul Du Bois dubois at doublefine.com
Mon Jun 6 18:55:11 MDT 2011

The question seems more appropriate for python-list.  However, to try to
answer the question: modules can be passed around just as easily as
anything else.  Like you say, give your subroutines module an init

# project_main.py
import parameter1, parameter2, parameter3
import subroutines
subroutines.init(parameter1, parameter2, parameter3)

> I'd have to handle each and every value being imported to make it
global in the module.

No; just save off the modules:

# subroutines.py
def init(a,b,c):
    global ga, gb, gc
    ga,gb,gc = a,b,c

Alternatively, since you say "it's quite practical to pass the names of
the modules for a project (3 files)", instead of passing names pass

subroutines.do_something(parameter1, parameter2, parameter3, ...)

Caveat: I may not have understood your problem correctly.  In
particular, this bit made no sense to me:

> Importing in each function of the subroutines module makes no sense
and creating separate copy of the subroutines module just so the import
statements at the top have the proper hard-coded project module names
makes no sense either.


More information about the wingide-users mailing list