How to catch str exception?

Dave Angel davea at
Fri May 15 17:48:02 CEST 2009

anuraguniyal at wrote:
>> except TypeError,e:
>>     print "1",e # is caught here
>> 1 exceptions must be classes or instances, not str
> doesn't happen so in 2.5.2
I tested it in 2.6.2

Perhaps you could try something like:

    raise "xxx"
except Exception, e:
    print "1",e # is caught here
    ...and then test e.message and reraise if necessary

More information about the Python-list mailing list