I´m trying to use PyYAML to parse a YAML file into a python object
However I doubt raised during the course
I have the YAML file
first_lvl:
second_lvl:
item_a:
- value_a : "value aaa"
- value_b : "value bbb"
My python script reads and loads the YAML into an object
import yaml
class Struct:
def __init__(self, **entries):
self.__dict__.update(entries)
with open(job_file.yml) as f:
skeleton = yaml.full_load(f)
MyJob = Struct(**skeleton)
print(MyJob.first_lvl)
And that that works fine but only for the first level of the YAML. How about if I want to reach the sub-level values of yaml file that suppose to be contained into the object
like this :
print(MyJob.first_lvl.second_lvl)
It might not be related with a PyYAML module thing and more the way python handles objects, but I´m still lost
Can anyone shed some lights?