Consider:
stuff/
__init__.py
mylib.py
Foo/
__init__.py
main.py
foo/
__init__.py
script.py
script.py
wants to import mylib.py
.
This is just an example, but really I just want to do a relative import of a module in a parent directory. I've tried various things and get this error...
Attempted relative import beyond toplevel package
I read somewhere that the script from where the program starts shouldn't reside in the package, and I tried modifying the structure for that like so...
stuff/
mylib.py
foo.py // Equivalent of main.py in above
foo/
__init__.py
script.py
But I got the same error.
How can I accomplish this? Is this even an adequate approach?
In Python 2.