def get_vars(tree, doseq=False, ignore_tags=()):
    """

    >>> get_vars(parse('myobj.a = 42;'))
    {'myobj.a': 32}
    >>> get_vars(parse('''otherobj = [{a: 2, 3: "test"}];'''))
    {'otherobj': [{'a': 2, '3': 'test'}]}

    """
    vars = {}
    elements = tree.xpath('/program/*[self::var[@name] or self::assign[@operator="="]]')
    for el in elements:
        obj = make_obj(el, ignore_tags=ignore_tags)
        assert isinstance(obj, dict)
        if doseq:
            for key, val in obj.items():
                vars.setdefault(key, []).append(val)
        else:
            vars.update(obj)
    return vars
def get_vars ( tree , doseq = False , ignore_tags = ( ) ) : vars = { } elements = tree . xpath ( '/program/*[self::var[@name] or self::assign[@operator="="]]' ) for el in elements : obj = make_obj ( el , ignore_tags = ignore_tags ) assert isinstance ( obj , dict ) if doseq : for key , val in obj . items ( ) : vars . setdefault ( key , [ ] ) . append ( val ) else : vars . update ( obj ) return vars
>>> get_vars(parse('myobj.a = 42;'))
    {'myobj.a': 32}
    >>> get_vars(parse('''otherobj = [{a: 2, 3: "test"}];'''))
    {'otherobj': [{'a': 2, '3': 'test'}]}