Google App Engine’s Python Exception Syntax

Remember, Python 2.5 has this exception syntax:

try:
    raise FooException("Darn!")
except FooException, e
    print("Error: %s" % e)
The newer syntax is:
try:
    raise FooException("Darn!")
except FooException as e
    print("Error: %s" % e)
I ran into this when uploading an application to Google App Engine, which then produced this cryptic error:
<type 'exceptions.SyntaxError'>: invalid syntax (main.py, line 64)
Where line 64 is the line containing the not-yet-implemented as keyword.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>