In file foo.py I want to import class A from file main.py with the following folderStructur:
main.py
__init__.py
|-folder1
__init__.py
|-folder 2
__init__.py
foo.py
|-folder 3
...
How does the import-line has to look like?
I tried things like
from ..main import A
but i just got
ValueError: Attempted relative import in non-package
That error comes from how you’re running the file – if you want to do that relative import, you need to run your foo program like this:
(In other words, you need to be treating the package structure from which you are importing as an actual package.)