def urlquote(val):
 if (val is None):
  return ''
 if (not isinstance(val, unicode)):
  val = str(val)
 else:
  val = val.encode('utf-8')
 return urllib.quote(val)

def urlquote ( val ) : if ( val is None ) : return '' if ( not isinstance ( val , unicode ) ) : val = str ( val ) else : val = val . encode ( 'utf-8' ) return urllib . quote ( val )
quotes a string for use in a url .