For an anytree
Node
, how can I get all the attributes and their values?
For example, if I do:
>>> from anytree import Node
>>> root = Node("root")
>>> s0 = Node("sub0", parent=root, foo="10", bar="ggg")
how can I get something like [("foo", "10"), ("bar", "ggg")]
?
I can think of a route via the following:
>>> s1=Node("dummy", parent=root)
>>> set(dir(s0))-set(dir(s1))
{'foo', 'bar'}
but I hope there is a more concise way.