Shuaib wrote:
> 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)

Have you imported xml.parsers.expat to get it properly scoped?

> 
> Also, how do I get the line number where an exception was thrown?
> 
Try looking at the 'sys.exc_info' and the 'traceback' module 
documentation. Also see Python Cookbook recipe Recipe 8.6. Getting More 
Information from Tracebacks (Bryn Keller)

                

> Thanks.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to