I can’t import a class from a file, even though I can import other Classes from the same file.
My Filestructure is
maindir
- test.py
- neat
- __init__.py
- reporting.py
The reporting.py file looks something like this
class A:
pass
class B(A):
pass
class C(A);
pass
The __ init__.py looks like this
from neat.reporting import B, C # But C can't be found
And of course in test.py I can use B but not C
import neat
b = B() # works
c = C() # throws class not found
I tried renaming the class, moving it to a different position in the file, removing class B, restarting the program, importing using * and using class C in the same file (which works).
The only thing that fixed the error was moving C to a new file and importing that, but I would at least like to understand why it wasn’t working
nicht soeren is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.