I'm Nagi Goishi, who recently works in Python and scikit-learn. Personally, I'm more of a Ruby fan than Python, but I like the one I'm introducing here in the Python specification.
import
Python beginners like me have a strong image of ʻimport loading the library. However, you can use ʻimport
to load classes and methods written in other files.
helper.py
class Helper:
def some_help():
#Algorithms that help
app.py
from helper import Helper
Helper().some_help()
Project
- helpers
- helper.py
- app.py
In cases like
app.py
from helpers.helper import Helper
Or
app.py
from helpers import helper
from helper import Helper
Project
- helpers
- base_helper.py
- helper.py
- app.py
If you want to use the BaseHelper
class of helper.py
in base_helper.py
with a structure like
helper.py
from helpers.base_helper import BaseHelper
# from helpers import base_helper
# from base_helper import BaseHelper
#I don't know why, but I couldn't. Please tell me who understands.
app.py
from helpers.helper import Helper
Recommended Posts