A class with eventhandlers ?

Alex Martelli aleax at mail.comcast.net
Sun Jan 29 23:56:26 EST 2006


Runsun Pan <python.pan at gmail.com> wrote:
   ...
> or, more specific, a function/method-specific error
> handling feature:
> 
> c.load.onError( IOErrorHook)
> c.load( filename )
> 
> Is there such a mechnism around? If not, is it possible
> to make such a thing ?

Never heard of one, but you could surely make a custom metaclass
satisfying your specs (==wrapping each method into an instance of a type
providing such an onError method, as well as a __call__ delegating to
the real method within a suitable try/except).  Sounds like a lot of
work to me, though;-).


Alex



More information about the Python-list mailing list