Reputation: 742
In my project each class is a file and my directory structure like this:
main.py
myGui/
__init__.py (empty)
ClassA.py
ClassB.py
To use my classes In main.py I need import with:
from myGui.ClassA import ClassA
from myGui.ClassB import ClassB
How to import with:
from myGui import ClassA, ClassB
Upvotes: 3
Views: 1570
Reputation: 1087
Assuming you added them to your __ init__.py,
from . import ClassA, ClassB
Should work.
Upvotes: 0
Reputation: 1485
You can add this into your __init__.py
from .ClassA import ClassA
from .ClassB import ClassB
And then import them like you mentioned
Upvotes: 4