I have a dictionary in python that represents a directory structure, so something like
dict = {
"file1.java": {
"method1": [],
"method2": []
},
"dir1": {
"file2.java":{
.
.
.
},
"dir2": {
"file3.java": {
"method3": ["hello", "hi"],
"method4": []
"file4.java": {
}
}
}
I also have have a list of strings like
list = ["dir1", "dir2", "file3.java", "method3"]
Is there an easy way to traverse the dictionary to access the data in method3 using the list So I would like to be able to call
dict[list]
and have it do something like
dict["dir1"]["dir2"]["file3.java"]["method3"]
and return something like
["hello", "hi"]
but I have no idea how long the list of strings will be so the list
list = ["file1.java","method1"]
also needs to work