code: def as_unicode(s, encoding='utf-8'):
      
      if isinstance(s, six.text_type):
          return s
      elif isinstance(s, six.binary_type):
          return s.decode(encoding)
      else:
          raise ValueError('Can only convert types {0} and {1}'.format(six.text_type, six.binary_type))
docs: Force conversion of given string to unicode type.
      Unicode is ``str`` type for Python 3.x and ``unicode`` for Python 2.x .
  
      If the string is already in unicode, then no conversion is done and the same string is returned.
  
      Parameters
      ----------
      s: str or bytes (Python3), str or unicode (Python2)
          The string to convert to unicode.
      encoding: str
          The encoding of the input string (default: utf-8)
  
      Raises
      ------
      ValueError
          In case an input of invalid type was passed to the function.
  
      Returns
      -------
      ``str`` for Python3 or ``unicode`` for Python 2.