code: def to_string(s, encoding='utf-8'):
      
      if six.PY2:
          return s.encode(encoding)
      if isinstance(s, bytes):
          return s.decode(encoding)
      return s
docs: Accept unicode(py2) or bytes(py3)
  
      Returns:
          py2 type: str
          py3 type: str