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 522695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:22:51+00:00 2026-05-13T08:22:51+00:00

am wondering if I’m doing this right. I want to split a huge py

  • 0

am wondering if I’m doing this right.

I want to split a huge py file into ten .py files ( or controllers, if you
will). The reason being it’s neat, and doesn’t contain thousands of code lines in one single file.

Every .py file will have its own request handler.

Each .py file will serve a certain function.

(the questions come after the Code section)

Code:

# *****app.yaml***** 
handlers: 
url: /part1 
script: controllers/part1.py 
url: /part2 
script: controllers/part2.py 
# this goes on until part10.py 


# ***** part1.py (this is the entry point of the application)***** 
# all required imports ( about 20 imports, some from app engine, some from external libs ) 

class Part1(webapp.RequestHandler): 

  # a lot of code here 
  # Models are accessed, data retrieved and worked upon. Results of the work are    
  # sent directly to the template_values variable

  # point to template 
  path = os.path.join(os.path.dirname(__file__), 'templates/part1.html')

  template_values = { 'variable ':variable } 
  # render template 
  self.response.out.write(template.render(path, template_values)) 

  # the standard WSGI calls 
  application = webapp.WSGIApplication([('/part1', Part1)],debug=True) 

def main(): run_wsgi_app(application) 
if __name__ == "__main__": main() 

Additional notes:
for part2.py until part10.py, it follows the exact same format as
part1.py.

So far it’s been working for me on both dev and production server.

My worries:
1. Am I taxing the app engine server bcos the imports in each .py file are repetitive?
2. Is it okay to have a request handler for each .py file? Am I consuming too much resource?

The big question is, can I keep doing this as my application grows ( as
I add more code/functionality) ? Is this the way to expand all the way
up to N numbers of .py files? What are the drawbacks?

Hope you guys can give some insights on this.

Been thinking about this for weeks.

  • 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-05-13T08:22:52+00:00Added an answer on May 13, 2026 at 8:22 am

    If those are “parts” to the same application, you should separate them using URL mappings instead, this way maintenance is easier (since the url endpoints will be “centralized” and you’ll be editing them in python) and everything gets more concise (app.yaml maps applications).

    Read this for clarification

    You’d basically add new mappings to several different handlers and organize those as python modules.

    (...)
    from myapp import Part1, Part2 # etcetera
    
    (...)
    application = webapp.WSGIApplication([('/part1', Part1), ('/part2', Part2])])
    

    In case you’re having trouble modularizing your python code, perhaps reading the official docs will help.

    EDIT:

    My answer above is basically the same as the first one, it wasn’t there when I started answering, sorry.

    A little more clarification on why this is better than having each part as a separate application:

    • Module loading will only happen once per application restart
    • If you check your appengine dashboard, some modules may take a long time to load (mostly when they’re big, obviously)
    • Profiling your whole set would be just a matter of adding a Middleware to application.

    Even with all that, I think the most important point would be: code organization will be way easier to accomplish since you can separate applications and logics in individual packages/applications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering if this is even possible or a limitation of PHP, googling around seems
Wondering if anyone has a solution to this 2010 bug. I have a project
Wondering what others do / best practice for communicating between layers. This question relates
I have some data like this: 1 2 3 4 5 9 2 6
Wondering if there's any accepted practice for approximating C++'s 'const methods' in Objective-C. (new
Wondering what would be a good method to get the first iteration on a
wondering if anyone can help me. I've been searching for a few days for
Wondering if its' possible to have solution within solution in vs 2010? How? thanks
Wondering what the differences between REST and JSON APIs are, how you interface with
Wondering if it is a good or bad ideal to make use of Hibernate

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.