O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The try Statement

The try statement specifies a way to handle exceptions. One form is the following:

try:
      suite
except expression-target:
      suite
except:
      suite

which can have one or many except clauses—the exception handlers. If an exception occurs in the try clause's suite of statements, an exception handler that best fits it will be invoked. An except clause that doesn't have an expression target can act as a catchall bucket. If an exception doesn't have a specific exception handler and an except clause without an expression target is present, the exception will go to that clause.

The Call Stack

A call stack represents the order of called functions. For example, if a module calls function A() and function A() calls function B() and function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required