Let's say hypothetically you had a variable called list_a
. Sometimes the objects inside are themselves also lists, so multiple indexing might be needed depending on what you want.
You have the following dictionary:
field_dict = {
'name':[1],
'birthdate':[2,5],
'gender':[5,1,3]
}
Each value in the lists above represent how to index list_a
to access the needed value.
To get a person's name, I just need to index list_a
once, like this: list_a[1]
.
To access their birthdate, I do list_a[2][5]
. This is where the multiple indexing comes in. Likewise, to access gender, I do list_a[5][1][3]
.
I wonder what the most elegant implementation of this would be - the only solutions I can think of would involve a bit of bruteforcing in the way of hard-coding some details excessively.