doesNotUnderstand ?

Oleg Broytmann phd at phd.pp.ru
Wed Nov 28 11:48:19 EST 2001


On Wed, Nov 28, 2001 at 01:35:18PM -0300, Gerardo Richarte wrote:
>     Is there a way to intercept the activation of messages which are
> not implemented?

   There is, but I recommend to test if the object understands the
"message" (method, in Python termins):

   if hasattr(object, "seelctAll"):
      result = object.selectAll()

   If you really want to "intercept" an error: Python does it using
try-except operator. If an object does not implement a "message", this is
AttributeError:

   try:
      result = object.selectAll()
   except AttributeError:
      result = default

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list