Control module imports
Let's imagine following structure
Empty __init__.py
This way, if you need to use both classes in __main__.py
, you will need to import like this:
Importing name
Which can get redundant, so in A
__init__.py
we will do the following:
Now we can access this way:
main.py
Simple and direct to the point, you can repeat same for ClassB in its respective __init__.py
Customizing imported name
Note that __all__
should always be a list of strings with names that you've imported. If I would want to change imported name, I could:
__init.py__
main.py