In this answer it was described how to edit specific entries of yaml files with python. I tried to use the code for the following yaml file
- fields: {domain: "www.mydomain.com", name: "www.mydomain.com"}
model: sites.site
pk: 1
but with
with open('my.yaml', 'r') as f:
doc = yaml.load(f)
txt = doc["fields"]["domain"]
print txt
I get the error
Traceback (most recent call last):
File "./test.py", line 9, in <module>
txt = doc["fields"]["domain"]
TypeError: list indices must be integers, not str
Now, I thought I could use keys on doc
.. Can somebody help me? :)