Suppose I have function that traverses through a python data structure and returns all the paths of the data Im looking to parse in a list format:
['section', 'section', 'section', 1, 'name', ]
['section', 'section', 'section', 1]
['section', 'section']
I then have another function that iterates through the same json to parse the data
with open(json_file) as data_file:
json_202 = data.load(data_file)
def parseJson(*argv) :
for arg in argv:
#do stuff
section1 = json_202["section"]["section"]["section"][1]["name"]
section2 = json_202["section"]["section"]["section"][1]
section3 = json_202["section"]
I call this function like so:
parseJson(section1, section2, section3)
What is a more pythonic approach of dynamically converting the list results from the first function to a format that matches 2nd function instead of hard cording section1
, section2
, section3