Is there a way to define a XPath type query for nested python dictionaries.
Something like this:
foo = { \'spam\':\'eggs\', \'morefoo\': {
Not exactly beautiful, but you might use sth like
def xpath_get(mydict, path): elem = mydict try: for x in path.strip("/").split("/"): elem = elem.get(x) except: pass return elem
This doesn't support xpath stuff like indices, of course ... not to mention the / key trap unutbu indicated.
/