def name_value_to_dict(content):
 result = {}
 for match in re.finditer('^([A-Za-z_][A-Za-z0-9_]*) *= *([^#]*)', content, re.MULTILINE):
  result[match.group(1)] = match.group(2).strip()
 return result

def name_value_to_dict ( content ) : result = { } for match in re . finditer ( '^([A-Za-z_][A-Za-z0-9_]*) *= *([^#]*)' , content , re . MULTILINE ) : result [ match . group ( 1 ) ] = match . group ( 2 ) . strip ( ) return result
converts a list of name=value pairs to a dictionary .