Reputation: 369
crispy13/
__init__.py
core/
__init__.py
ecf.py
How can i load the ecf module in the following ways?
from crispy13 import ecf
OR
from crispy13.ecf import *
instead of
from crispy13.core.ecf import *
Upvotes: 0
Views: 38
Reputation: 6234
like sahasrara62 said it can be done in the following manner
in crispy13/__init__.py
import your module as
from .core import ecf
you can also make use of __all__
variable in your __init__.py
file.
This is a very good way of importing modules/functions/classes.
Little bit insight to why we do imports in this way.
Let's suppose you are using a third-party
library/package and there are some implementation changes in the module
then your import will break.
That's why all third party libraries/packages include all of their consumable functions/classes/modules
in the root __init__.py
file of their package.
Upvotes: 1
Reputation: 11238
in crispy13/__init__.py
import the package as
from .core import ecf
Upvotes: 1