def _url_quote(string, encoding):
 if encoding:
  if isinstance(string, unicode):
   s = string.encode(encoding)
  elif isinstance(string, str):
   s = string
  else:
   s = unicode(string).encode(encoding)
 else:
  s = str(string)
 return urllib.quote(s, '/')

def _url_quote ( string , encoding ) : if encoding : if isinstance ( string , unicode ) : s = string . encode ( encoding ) elif isinstance ( string , str ) : s = string else : s = unicode ( string ) . encode ( encoding ) else : s = str ( string ) return urllib . quote ( s , '/' )
a unicode handling version of urllib .