def join_options(options):
 rv = []
 any_prefix_is_slash = False
 for opt in options:
  prefix = split_opt(opt)[0]
  if (prefix == '/'):
   any_prefix_is_slash = True
  rv.append((len(prefix), opt))
 rv.sort(key=(lambda x: x[0]))
 rv = ', '.join((x[1] for x in rv))
 return (rv, any_prefix_is_slash)

def join_options ( options ) : rv = [ ] any_prefix_is_slash = False for opt in options : prefix = split_opt ( opt ) [ 0 ] if ( prefix == '/' ) : any_prefix_is_slash = True rv . append ( ( len ( prefix ) , opt ) ) rv . sort ( key = ( lambda x : x [ 0 ] ) ) rv = ', ' . join ( ( x [ 1 ] for x in rv ) ) return ( rv , any_prefix_is_slash )
given a list of option strings this joins them in the most appropriate way and returns them in the form where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash .