By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

Module Importing Question

P: n/a
Hello All,

I have two modules that I use interchangably depending on the circumstances.
These modules are imported by yet another module. I want the "importation" of
these two alternatives to be mutually exclusive and dependent on the state of
the "outermost module"

A diagram:

mainApp ==imports==> aModule ==imports==> [oneMod | orTheOtherMod]

I want the importing of oneMod or orTheOtherMod to depend on the state of the
mainApp. aModule is frozen, as are oneMod and orTheOtherMod. How might I
accomplish this? I realize that this is a workaround for poorly thought out
dependencies, but in my defense, have you seen just about anything else in
this world (California Freeways, Tax Forms, A Flow-Chart of Human Metabolic
Pathways, umm...whatever)?

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Oct 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
James Stroud wrote:
Hello All,

I have two modules that I use interchangably depending on the circumstances.
These modules are imported by yet another module. I want the "importation" of
these two alternatives to be mutually exclusive and dependent on the state of
the "outermost module"

A diagram:

mainApp ==imports==> aModule ==imports==> [oneMod | orTheOtherMod]

I want the importing of oneMod or orTheOtherMod to depend on the state of the
mainApp. aModule is frozen, as are oneMod and orTheOtherMod. How might I
accomplish this?


I don't know what you mean by frozen, so maybe this is no good, but I would avoid having aModule look back at the state of mainApp. Instead use another module to communicate state. This could be a simple as

# in mainApp
import helper
if something:
import oneMod as theMod
else:
import orTheOtherMod as theMod
helper.theMod = theMod

import aModule

# in aModule
import helper.theMod as theMod
theMod.someFunction()

Kent
Oct 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.