Question

The webapp2.WSGIApplication class is initialized with three arguments:

  1. routes: list of tuples
  2. debug: enable / disable debug mode
  3. config: dictionary of config values

Why is the first argument a list of tuples and not a dictionary?

Was it helpful?

Solution

My guess is that the order of the tuples is important, and a dictionary has no order.

app = webapp2.WSGIApplication([
  ('/this page', ThisPageHandler),
  ('.*', FrontPage),
  ],debug=False)

If that was your app above, it's important to catch the /this_page route before the catch all .* is caught. A list preserves order where a dictionary does not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top