I have a python application with the following structure.
/app
/models
__init__.py
profile.py
/views
__init__.py
index.py
login.py
__init.py
main.py
Currently the three __init__.py files are empty.
In the files like index.py, I have several classes.
class IndexHandler(webapp2.RequestHandler):
#blah blah
What do I write in the __init.py__ files such that I can call the classes in profile.py, index.py and so on without typing the full package path?
Namespaces in Python are explicit. In each
__init__.pyfile, import whatever modules, functions, and classes you would like to be available within the namespace of that package.For example, if you would like the
apppackage to have anindexmember, in/app/__init__.py:Or if you would like the class itself to be part of the namespace:
This will allow you to do: