It is advisable to import all of your handlers at application startup, in order to take advantage of the lapp bootloader of the webapp2 bootloader , which loads modules / packages as needed.
Thus, you have several options:
Option 1, Handlers in the module
Place MainPagein another file (module) at the same level as your file helloworld.py:
/ my_gae_app
app.yaml
helloworld.py
handlers.py
And in your routing (c helloworld.py) you would do:
app = webapp2.WSGIApplication([('/', 'handlers.MainPage'),
('/sign', 'handlers.Guestbook')],
debug=True)
Option 2, Handlers in a package; perhaps they think your application is getting bigger
As your application grows in size, you can create a package to host your handlers:
/ my_gae_app
/ handlers
__init__.py
guestbook.py
main.py
app.yaml
helloworld.py
( helloworld.py):
app = webapp2.WSGIApplication([('/', 'handlers.main.MainPage'),
('/sign', 'handlers.guestbook.Guestbook')],
debug=True)