def _combine_ws(parts, whitespace):
 out = []
 ws = ''
 for part in parts:
  if (not part):
   continue
  elif (part in whitespace):
   ws += part
  else:
   out.append((ws + part))
   ws = ''
 if ws:
  out.append(ws)
 return out

def _combine_ws ( parts , whitespace ) : out = [ ] ws = '' for part in parts : if ( not part ) : continue elif ( part in whitespace ) : ws += part else : out . append ( ( ws + part ) ) ws = '' if ws : out . append ( ws ) return out
combine whitespace in a list with the element following it .