I have a nested dictionaries
root ={
'user':{
'Johnson':{
'incoming':2000,
'family' :4,
'play':None
}
'Smith':{
'incoming':17000,
'family' :1,
'play':False
}
}
}
I can access any record but only with a lot of syntax: root['user']['Smith']['play']
I want to expand the syntax, somehow, to be able do like this:
print "Johnson incoming", root['/user/Johnson/incoming']
root['/user/Smith/play'] = True
Distinguishing from some potential duplicates:
- Object-like attribute access for nested dictionary describes how to achieve
root.user.Smith.play
, but notroot['/user/Smith/play']
. - Xpath like query for nested python dictionaries is providing functions, rather than syntax extensions, and doesn't support assignment.