Assuming I have a python package with the following structure:
folder1
__init__.py
main.py
subfolder1
__init__.py
submain.py
subagent.py (contains class Agent)
subnetwork.py (contains class Network)
In the subagent.py file I import the Network class and in main.py and submain.py I import the Agent class. I would like to be able to start my program from both main.py and submain.py. However this causes problem in the subagent.py file. If I start from main.py I have to write the imports in subagent.py like that:
from subfolder1.subnetwork import Network
However if I start from submain.py I have to write the imports in subagent.py like that:
from subnetwork import Network
Is there an elegant solution to tackle this problem?