This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients Chenyun Yang, ezio.melotti, josh.r, martin.panter, xiang.zhang
Date 2015-10-02.22:13:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443824035.29.0.188037367081.issue25258@psf.upfronthosting.co.za>
In-reply-to
Content
> this inconsistent cannot be fixed from the inherited class as (handle_* 
> calls are dispatched in the internal method of HTMLParser)

You can override handle_startendtag() like this:

>>> class MyHTMLParser(HTMLParser):
...     def handle_starttag(self, tag, attrs):
...         print('start', tag)
...     def handle_endtag(self, tag):
...         print('end', tag)
...     def handle_startendtag(self, tag, attrs):
...         self.handle_starttag(tag, attrs)
... 
>>> parser = MyHTMLParser()
>>> parser.feed('<link rel="import"/><img src="som"/>')
start link
start img


(P.S. please don't quote the whole message in your reply)
History
Date User Action Args
2015-10-02 22:13:55ezio.melottisetrecipients: + ezio.melotti, martin.panter, josh.r, xiang.zhang, Chenyun Yang
2015-10-02 22:13:55ezio.melottisetmessageid: <1443824035.29.0.188037367081.issue25258@psf.upfronthosting.co.za>
2015-10-02 22:13:55ezio.melottilinkissue25258 messages
2015-10-02 22:13:55ezio.melotticreate