def NameValueListToDict(name_value_list):
 result = {}
 for item in name_value_list:
  tokens = item.split('=', 1)
  if (len(tokens) == 2):
   try:
    token_value = int(tokens[1])
   except ValueError:
    token_value = tokens[1]
   result[tokens[0]] = token_value
  else:
   result[tokens[0]] = True
 return result

def NameValueListToDict ( name_value_list ) : result = { } for item in name_value_list : tokens = item . split ( '=' , 1 ) if ( len ( tokens ) == 2 ) : try : token_value = int ( tokens [ 1 ] ) except ValueError : token_value = tokens [ 1 ] result [ tokens [ 0 ] ] = token_value else : result [ tokens [ 0 ] ] = True return result
takes an array of strings of the form name=value and creates a dictionary of the pairs .