def url_concat(url, args, fragments=None):
 if ((not args) and (not fragments)):
  return url
 while (url[(-1)] == '#'):
  url = url[:(-1)]
 fragment_tail = ''
 if fragments:
  fragment_tail = ('#' + urlencode(fragments))
 args_tail = ''
 if args:
  if (url[(-1)] not in ('?', '&')):
   args_tail += ('&' if ('?' in url) else '?')
  args_tail += urlencode(args)
 return ((url + args_tail) + fragment_tail)

def url_concat ( url , args , fragments = None ) : if ( ( not args ) and ( not fragments ) ) : return url while ( url [ ( - 1 ) ] == '#' ) : url = url [ : ( - 1 ) ] fragment_tail = '' if fragments : fragment_tail = ( '#' + urlencode ( fragments ) ) args_tail = '' if args : if ( url [ ( - 1 ) ] not in ( '?' , '&' ) ) : args_tail += ( '&' if ( '?' in url ) else '?' ) args_tail += urlencode ( args ) return ( ( url + args_tail ) + fragment_tail )
concatenate url and arguments regardless of whether url has existing query parameters .