Reputation: 10021
I'm creating a module in a python app, I have my primary code file, and I want to import some helper methods/classes from a helper folder. This is what I have for my folder structure:
module:
__init__.py
helpers:
__init__.py
some_class.py
this is module/helpers/__init__.py
file:
from .some_class import SomeClass
def helper_method_1():
# code
def helper_method_2():
# code
so my question is: is importing SomeClass
inside module/helpers/__init__.py
inside the helpers
enough to use it as in import in my main module/__init.py
file?
this is what I'm trying in my module/__init__.py
from .helpers import (SomeClass, helper_method_1, helper_method_2)
I'm kind of in the middle of doing a bunch of things, so can't test it for errors at the moment
Upvotes: 0
Views: 34
Reputation: 3582
Yes, it is enough.
Unless module has __all__
variable, all names (including names imported from other modules) are exported.
Upvotes: 1