| |
comp.lang.python |
In article <1180977447.745432.109...@q19g2000prn.googlegroups.com>, >> If I'm not mistaken, in python, there's no standard library to convert >> htmlentitydefs provides maps that helps this conversion, >> To me this seemed odd because python is known as >> So my questions are >> Thank you in advance. >I think this is the standard idiom: >>>> import xml.sax.saxutils as saxutils >Notice there is an optional parameter (a dict) that can be used to It's possible that your solution is to a different problem than the original
>On Jun 4, 6:31 am, "js " <ebgs...@gmail.com> wrote:
>> Hi list.
>> html entities, like & or > into their applicable characters.
>> but it's not a function so you have to write your own function
>> make use of htmlentitydefs, probably using regex or something.
>> 'Batteries Included' language.
>> 1. Why doesn't python have/need entity encoding/decoding?
>> 2. Is there any idiom to do entity encode/decode in python?
>>>> saxutils.escape("&")
>'&'
>>>> saxutils.unescape(">")
>'>'
>>>> saxutils.unescape("A bunch of text with entities: & > <")
>'A bunch of text with entities: & > <'
>define additional entities as well.
.
.
Good points; I like your mention of the optional entity dictionary.
poster intended. <URL: http://wiki.python.org/moin/EscapingHtml > has de-
tails about HTML entities vs. XML entities.