Considering this project structure:
project
...
|-- view
|-- __init__.py
|-- app_view.py
|-- component.py
And these imports and declarations:
# __init__.py
from view.app_view import AppView
global APP_VIEW
APP_VIEW = AppView()
# app_view.py
from view.component import Component
class AppView:
def __init__(self):
self.component = Component()
# component.py
from view import APP_VIEW
class Component:
...
ImportError: cannot import name 'APP_VIEW'
Is the message I've been receiving and I suppose there's something related with the cyclic import structure, but I tried some other organizations without success. So I was wonder how to solve this situation.
- What is the Pythonic file structure for related modules like this?
- How should I store a global variable to be able to import it along with the whole project?