Python access jsonable nested object with comma separated key

First lets create a nested object which is jsonable in python:

ExampleObject1 = [ {'a':0, 'b':1} ,  {'c':2, 'd':3} ]
ExampleObject2 = [ {'a':0, 'b':ExampleObject1} ,  {'c':2, 'd':3} ]
ExampleObject3 = [ {'a':0, 'b':ExampleObject1} ,  {'c':ExampleObject2, 'd':3} ]

We can easily access an element with chaining square brackets like so:

print ( ExampleObject3[0]['b'][0]['b'] )

>>> 1

How can I access the same element with a list of keys instead of needing the square brackets?

print ( ExampleObject3[ (0,'b',0,'b') ] )

>>> TypeError: list indices must be integers or slices, not tuple

NOTE – I CAN access numpy array’s this way.
As soon as I try to access a dictionary with comma separated key’s then things break.

See: Python Store Slice Index as Object

REASON: I just want to be able to pass around an arbitrary key which can be used to go get data later from some large object sitting in memory.

%d bloggers like this: