How do people get around this issue:
A controller (say controller.py) imports two models (say a_model.py and b_model.py):
from app.model import a_model
from app.model import b_model
Now let’s say that a_model wants to use a function in b_model (let’s say it wants to get something from b_model where an id of the record is from a query in a_model, so I do (in a_model):
from app.model import b_model
Now since our controller has already imported b_model.py and a_model.py is attempting to do the same, we break the application.
Can someone tell me the best way around this? Maybe use a proxy? Or a library loader?
There’s no problem with importing a module from two different modules in Python. Maybe your particular design makes it a problem, but it’s not something Python imposes.
Anyhow, you could probably solve the problem by moving common stuff from
a_modelandb_modelto some other module, i.e.model_common, and importing that from botha_modelandb_model.