Exceptions Python Exception mechanism similar to Java and C++ try: foo(x,y) z = spam / x except ZeroDivisionError: print "Can't Divide by Zero" except FooError, data: print "Foo raised an error", data except: print "Something went wrong" else: print "It worked!" User code can raise an error raise FooError, "First argument must be >= 0"