def split_first(s, delims):
 min_idx = None
 min_delim = None
 for d in delims:
  idx = s.find(d)
  if (idx < 0):
   continue
  if ((min_idx is None) or (idx < min_idx)):
   min_idx = idx
   min_delim = d
 if ((min_idx is None) or (min_idx < 0)):
  return (s, '', None)
 return (s[:min_idx], s[(min_idx + 1):], min_delim)

def split_first ( s , delims ) : min_idx = None min_delim = None for d in delims : idx = s . find ( d ) if ( idx < 0 ) : continue if ( ( min_idx is None ) or ( idx < min_idx ) ) : min_idx = idx min_delim = d if ( ( min_idx is None ) or ( min_idx < 0 ) ) : return ( s , '' , None ) return ( s [ : min_idx ] , s [ ( min_idx + 1 ) : ] , min_delim )
given a string and an iterable of delimiters .