def smart_split(s, delimiter=','):
  """Split e.g., "a=5,b=5,2,c=4", into ['a=5', 'b=5,2', 'c=4']."""
  tokens = []
  for token in s.split(delimiter):
    if token.find('=') != -1:  # has '=' sign, so it's the right split
      tokens.append(token)
    else:  # no '=' sign, incorrect split, so merge
      tokens[len(tokens) - 1] += delimiter + token
  return tokens