File: class/Extras/Other/PriorClasses/nasa-ksc-aug15/excs1.py

# lib.py

class MathErr(Exception):  pass

class DivZero(MathErr): pass
class Uflow(MathErr):   pass
class Oflow(MathErr):   pass


def f1():
    ....
    raise DivZero(.......)
    ...
    raise Uflow()

------------

# client.py

import lib

try:
    lib.f1()
except lib.MathErr as E:
    E.method()
    if isinstance(E, lib.Uflow):
...


sys.exit(N)



[Home page] Books Code Blog Python Author Train Find ©M.Lutz