def to_native_string(string, encoding='ascii'):
 if isinstance(string, builtin_str):
  out = string
 elif is_py2:
  out = string.encode(encoding)
 else:
  out = string.decode(encoding)
 return out

def to_native_string ( string , encoding = 'ascii' ) : if isinstance ( string , builtin_str ) : out = string elif is_py2 : out = string . encode ( encoding ) else : out = string . decode ( encoding ) return out
given a string object .