How do I catch ExpatError exception?

Shuaib aries.shuaib at gmail.com
Wed Aug 16 19:36:24 EDT 2006


Hey!

I am getting this exception.

xml.parsers.expat.ExpatError

But I am not able to catch it with "except
xml.parsers.expat.ExpatError:" It says "NameError: global name 'xml' is
not defined".

I am also not able to catch it with "except ExpatError:" Gives
"NameError: global name 'xml' is not defined"

How do I catch it? (I am parsing an xml file)

Also, how do I get the line number where an exception was thrown?

Thanks.




More information about the Python-list mailing list