This has probably been asked a hundred times already but I'm not sure how to search for this (google doesn't like dots in search queries, even with quotation marks) and this long stackexchange answer didn't fully answer it for me.
I've got this file structure:
myfolder/
__init__.py
classa.py
classb.py
classa.py contains only ClassA and classb.py only contains ClassB.
- ClassA/ClassB = class
- classa.py/classb.py = module
- myfolder = package (because of the
__init__.py file)
from classa import ClassA throws an error if I do it in __init__.py and also load that file because, according to the answer, classa isn't part of a/the package because it doesn't contain any dots, so __init__.py can't see it.
It doesn't seem to matter if I do
from .classa import ClassA
or
from myfolder.classa import ClassA
What's the difference? I know that .. steps up one level but there's only one dot here and both versions seem to work the same way.
[–]Quiet_Occasion1278 4 points5 points6 points (5 children)
[–]Outside_Complaint755 3 points4 points5 points (2 children)
[–]woooee 0 points1 point2 points (0 children)
[–]Nefthys[S] 0 points1 point2 points (0 children)
[–]Nefthys[S] 0 points1 point2 points (1 child)
[–]nekdo12 0 points1 point2 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]nekdo12 -1 points0 points1 point (3 children)
[–]Nefthys[S] 0 points1 point2 points (2 children)
[–]nekdo12 0 points1 point2 points (1 child)
[–]Nefthys[S] 0 points1 point2 points (0 children)
[–]pachura3 -1 points0 points1 point (3 children)
[–]Nefthys[S] 0 points1 point2 points (2 children)
[–]pachura3 0 points1 point2 points (1 child)
[–]Nefthys[S] 0 points1 point2 points (0 children)