Oct 03, 2007 15:08
Quickest way to escape HTML entities:
lambda astring: reduce(lambda x, y: x.replace(*y), [astring, ('&', '&'), ('<', '<'), ('>', '>')])
Example:
omg = lambda astring: reduce(lambda x, y: x.replace(*y), [astring, ('&', '&'), ('<', '<'), ('>', '>')])
omg("Hello & Hello <")