parameters: (self, s, encoding=None)
return_statement: return s
docstring: Encodes an object to a string in some encoding, or to Unicode.
          .
docstring_summary: Encodes an object to a string in some encoding, or to Unicode.
          .
docstring_tokens: Encodes an object to a string in some encoding or to Unicode . .
function: def toEncoding(self, s, encoding=None):
          """Encodes an object to a string in some encoding, or to Unicode.
          ."""
          if isinstance(s, unicode):
              if encoding:
                  s = s.encode(encoding)
          elif isinstance(s, str):
              if encoding:
                  s = s.encode(encoding)
              else:
                  s = unicode(s)
          else:
              if encoding:
                  s  = self.toEncoding(str(s), encoding)
              else:
                  s = unicode(s)
          return s
function_tokens: def toEncoding ( self , s , encoding = None ) : if isinstance ( s , unicode ) : if encoding : s = s . encode ( encoding ) elif isinstance ( s , str ) : if encoding : s = s . encode ( encoding ) else : s = unicode ( s ) else : if encoding : s = self . toEncoding ( str ( s ) , encoding ) else : s = unicode ( s ) return s