Splitting Code in different Files - Python / App Engine
Question: I have multiple classes and everything is in a single main.py file which is
getting really messy...

I'm new to Python however I've taken a couple of courses now and I'm getting
quite good but in none of the lessons was a reference on how to do this...

The main problem I have is I don't understand how splitting code works in
Python and what I have to re-import in every file... So rather then an answer
I would love some documentation or preferably a video tutorial on this.

I'll give you some sample code:

    
    
    class MainHandler(webapp2.RequestHandler, usersHandler, postsHandler):
    class usersHandler(DdHandler):
    class DdHandler():
    

I want to have each class in a separate file kinda like Java and C#


Answer: You are looking for how to divide your code into modules:
<http://docs.python.org/2/tutorial/modules.html>

You might not always want one file for each class, but rather a logical
grouping of classes. In your case you might have a file named db.py where you
put usersHandler and DbHandler

In your main file you would then do something like

    
    
    import db
    
    db_handler = db.DbHandler()
    

Also keep in mind that class names should start with an upper case,
UsersHandler instead of usersHandler. See more conventions at
<http://www.python.org/dev/peps/pep-0008/>

