Catching exception information from ExpatError

P

python newbie

Hey
Straightforward question:
I'm opening an xml file with minidom.

When I have a mismatch in the XML file, I simply want my python script to
not only stop gracefully, but also to call up UltraEdit with that xml file,
and highlighting the offending line (keep in mind UEdit can take command
line argument with the row and column)

When I let the exception be caught by default, I notice that I get:
xml.parsers.expat.ExpatError: mismatched tag: line 19, column 7

But when I catch the error with: except exp.ExpatError:
and then get the information from sys.exc_info(), it returns a tuple that
doesn't help:

class xml.parsers.expat.ExpatError at 0x00F7FF90>,
<xml.parsers.expat.ExpatError instance at 0x00FFD800>, <traceback object at
0x00FFD8C8>)


I want to somehow get the more useful: "line 19, column 7" and parse that
and call ultraedit with the 19 and the 7.

Can you suggest something, is it obvious?
thanks
Steve
 
P

python newbie

Thanks Diez,
I'll make that the first site that I visit when I have questions, as well.
 
D

Diez B. Roggisch

Thanks Diez,
I'll make that the first site that I visit when I have questions, as
well.

Good decision - the nice thing on python is thats more or less everything
you want to know is already out there - and especially on python.org ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top