class based exceptions

Fredrik Lundh fredrik at pythonware.com
Tue Apr 24 12:30:02 EDT 2001


Bruce Edge wrote:
> Can one associate an exception handler with all member functions of a
> class without explicitly coding it in every member?

how about:

> class wrap:
>   def __init__(self):
>     self.resolve()
>
>   def resolve(self)
>     #resolve corba reference

    def do(self, func, args):
        try:
            return apply(func, args)
        except omniORB.CORBA.COMM_FAILURE
            self.resolve()
            return apply(func, args)

    def read(self, ...)
        return self.do(corba.read, (...))

    def write(self, ...)
        return self.do(corba.write, (...))

Cheers /F





More information about the Python-list mailing list