How to make a conditional import???
Steven D. Majewski
sdm7g at minsky.med.Virginia.EDU
Fri Nov 10 12:19:30 EST 2000
>
>def selectProjectType():
> #... skipped
> if projectType == 'phys':
> from pyhsModule import *
> else:
> from logicModule import *
>
for a more global effect, try instead:
import sys
if projectType == 'phys' :
import physModule
sys.modules['theModule'] = physModule
else:
import logicModule
sys.modules['theModule'] = logicModule
and then anywhere, you can do:
import theModule
or
from theModule import *
import will find 'theModule' in the cache and it won't look for
a file of that name.
-- Steve Majewski <sdm7g at Virginia.EDU>
More information about the Python-list
mailing list