diff options
Diffstat (limited to '_example/map_insert.py')
-rw-r--r-- | _example/map_insert.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/_example/map_insert.py b/_example/map_insert.py new file mode 100644 index 0000000..ab3486a --- /dev/null +++ b/_example/map_insert.py @@ -0,0 +1,13 @@ +import sys +from ruamel.yaml import YAML + +yaml_str = """\ +first_name: Art +occupation: Architect # This is an occupation comment +about: Art Vandelay is a fictional character that George invents... +""" + +yaml = YAML() +data = yaml.load(yaml_str) +data.insert(1, 'last name', 'Vandelay', comment="new key") +yaml.dump(data, sys.stdout) |