Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:43:02+00:00 2026-06-18T09:43:02+00:00

I have a python application with the following structure. /app /models __init__.py profile.py /views

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:43:03+00:00Added an answer on June 18, 2026 at 9:43 am

    Namespaces in Python are explicit. In each __init__.py file, 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 app package to have an index member, in /app/__init__.py:

    from views import index
    

    Or if you would like the class itself to be part of the namespace:

    from models.views import IndexHandler
    

    This will allow you to do:

    import app
    handler1 = app.index.IndexHandler()  # example 1
    handler1 = app.IndexHandler()  # example 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my Python application, I have the following directories structure: \myapp \myapp\utils\ \myapp\utils\GChartWrapper\ \myapp\model\
I currently have a python/cherrypy application where the first page served-up is index.html, which
I have a Python application that is currently installed following Linux Filesystem Standard Hierarchy
In my Python application I have some GtkMenuItems (associated with the main GtkMenuBar), and
i am currently writing a python web-application running on google-app-engine using the webapp2 framework.
I have recently switched from python 2.7 to python 3.2 considering following folder structure:
I currently have a Python webserver application running and I would like to use
I have a Python application in which I would like to monitor the number
I have a Python application in the bottle web-server that accesses a C shared-object
I have a python (pygtk) application which starts in different modes depending on arguments.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.