[Tutor] Exception repeated in a loop
Jan Eden
lists at janeden.org
Tue Dec 6 16:29:59 CET 2005
Hi,
I use the following loop to parse some HTML code:
for record in data:
try:
parser.feed(record['content'])
except HTMLParseError, (msg):
print "!!!Parsing error in", record['page_id'], ": ", msg
Now after HTMLParser encounters a parse error in one record, it repeats to execute the except statement for all following records - why is that?
!!!Parsing error in 8832 : bad end tag: '</em b>', at line 56568, column 1647999
!!!Parsing error in 8833 : bad end tag: '</em b>', at line 56568, column 1651394
!!!Parsing error in 8834 : bad end tag: '</em b>', at line 56568, column 1654789
!!!Parsing error in 8835 : bad end tag: '</em b>', at line 56568, column 1658184
Thanks.
Jan
--
Hanlon's Razor: Never attribute to malice that which can be adequately explained by stupidity.
More information about the Tutor
mailing list