How does python import order affect names?
Contrary to what the other answer says, this is a circular import problem. app.__init__
tries to import app.views
, which tries to import the app.app
Flask
created in app.__init__
. If the Flask
is created before app.__init__
imports app.views
, app.views
finds app.app
. If the Flask
is created after the import, it isn't there yet when app.views
tries to find it.
Circular imports cause all sorts of horrible problems. It might be difficult, but the best way to handle them is generally to reorganize your code so there aren't circular imports.