| |
comp.lang.python |
As far as I know, there isn't a standard idiom to do this, but it's import re
still a one-liner. Untested, but I think this should work:
from htmlentitydefs import name2codepoint
def htmlentitydecode(s):
return re.sub('&(%s);' % '|'.join(name2codepoint), lambda m:
name2codepoint[m.group(1)], s)