I'm get an ImportError based on which file I call the modules from. Here's the directory tree:
my_package/
--base.py
--derived.py
--run1.py
run2.py
Note that run1.py is inside the my_package folder, while run2.py is outside the my_package folder.
# base.py
class Base:
...
To avoid the ImportError in run1.py, I need the following import statement in derived.py:
# derived.py
from base import Base
class Derived(Base):
...
To avoid the ImportError in run2.py, I need the following import statement in derived.py:
# derived.py
from . import base
class Derived(base.Base):
...
Is there a way to import the Base class into the Derived class and have it work from both run1.py and run2.py?