code: def escape(s):
      
      if hasattr(s, '__html__'):
          return s.__html__()
      if isinstance(s, six.binary_type):
          s = six.text_type(str(s), 'utf8')
      elif isinstance(s, six.text_type):
          s = s
      else:
          s = str(s)
  
      return (s
          .replace('&', '&amp;')
          .replace('>', '&gt;')
          .replace('<', '&lt;')
          .replace("'", '&#39;')
          .replace('"', '&#34;')
      )
docs: Convert the characters &, <, >, ' and " in string s to HTML-safe
      sequences.  Use this if you need to display text that might contain
      such characters in HTML.  Marks return value as markup string.