class MyException(ValueError):
    pass

def quam():
    return ZeroDivisionError

def foo():
    try:
        try:
            try:
                1/0
            except quam():
                print "zero divide"
            except:
                print "uhoh"
        finally:
            print "whatever"
        raise MyException, "testing"
    finally:
        print "last word"

def bar():
    try:
        x = 1
    except ValueError:
        pass
    else:
        print x
    try:
        foo()
    finally:
        print "passed the test"

def baz():
    try:
        bar()
    except ValueError, err:
        print err
    except KeyboardInterrupt:
        raise
    else:
        print "what went wrong?"

try:
    baz()
finally:
    print "finally"




