i have flask app.
app.py
app = flask(__name__) views import * if __name__=="__main__": app.run()
views.py
from app import app @app.route('/') def home(): return "homepage"
so, here app.py
importing form views.py
, views need app
defined in app.py
. still not causing circular import. why?
i run application using:
python app.py
this looks similar larger applications document flask allows when creating apps.
from docs:
circular imports
every python programmer hates them, , yet added some: circular imports (that’s when 2 modules depend on each other. in case
views.py
depends on__init__.py
). advised bad idea in general here fine. reason not using views in__init__.py
, ensuring module imported , doing @ bottom of file.
Comments
Post a Comment