sufficiently pythonic code for testing type of function

Theerasak Photha hanumizzle at
Wed Oct 11 10:37:48 CEST 2006

On 10/11/06, Bruno Desthuilliers <onurb at xiludom.gro> wrote:

> Now the real question : what if the object is not an instance of any of
> the types, but still support the expected interface ?


  for attribute in ['foo', 'bar', '__baz__']:
    getattr(mystery_object, '__%s__' % attribute)
except AttributeError:
  # Do sumthin bout it

Is it wrong to 're-raise' an exception with application-specific
details within an except clause?

-- Theerasak

More information about the Python-list mailing list