Testing whether something is of type Exception

Peter Decker pydecker at gmail.com
Thu Jan 24 18:12:28 EST 2008


On Jan 24, 2008 5:14 PM, John Nagle <nagle at animats.com> wrote:
>     How can I tell whether an object is of type Exception?
> At least in Python 2.4, "Exception" is an old-style class, and
> the "type" of Exception objects is "instance".
>
>     Clearly "repr" knows; it returns:
>         <exceptions.Exception instance at 0x00A30A80>

isinstance(x, Exception)


-- 

# p.d.



More information about the Python-list mailing list