code: def escape(cls, string):
          
  
          return ''.join([cls._escapes[c] if cls._needescape(c) else c
                          for c in string.encode('utf8')])
docs: Utility method to produce an escaped version of a given
          string.
  
          :param string: The string to escape.
  
          :returns: The escaped version of the string.