def htmlunescape(value):
 retVal = value
 if (value and isinstance(value, basestring)):
  codes = (('&lt;', '<'), ('&gt;', '>'), ('&quot;', '"'), ('&nbsp;', ' '), ('&amp;', '&'))
  retVal = reduce((lambda x, y: x.replace(y[0], y[1])), codes, retVal)
  try:
   retVal = re.sub('&#x([^ ;]+);', (lambda match: unichr(int(match.group(1), 16))), retVal)
  except ValueError:
   pass
 return retVal

def htmlunescape ( value ) : retVal = value if ( value and isinstance ( value , basestring ) ) : codes = ( ( '&lt;' , '<' ) , ( '&gt;' , '>' ) , ( '&quot;' , '"' ) , ( '&nbsp;' , ' ' ) , ( '&amp;' , '&' ) ) retVal = reduce ( ( lambda x , y : x . replace ( y [ 0 ] , y [ 1 ] ) ) , codes , retVal ) try : retVal = re . sub ( '&#x([^ ;]+);' , ( lambda match : unichr ( int ( match . group ( 1 ) , 16 ) ) ) , retVal ) except ValueError : pass return retVal
returns html unescaped value .