How do you htmlentities in Python

js ebgssth at gmail.com
Mon Jun 4 09:31:56 EDT 2007


Hi list.

If I'm not mistaken, in python, there's no standard library to convert
html entities, like & or > into their applicable characters.

htmlentitydefs provides maps that helps this conversion,
but it's not a function so you have to write your own function
make use of  htmlentitydefs, probably using regex or something.

To me this seemed odd because python is known as
'Batteries Included' language.

So my questions are
1. Why doesn't python have/need entity encoding/decoding?
2. Is there any idiom to do entity encode/decode in python?

Thank you in advance...



More information about the Python-list mailing list