My file, with the following content:
item1: bar
item2: foo
The code:
with open(filename, 'r') as file_content:
# perform a logic which modifies file content,
# for instance replaces every occurence of bar with baz
yaml_content = yaml.safe_load(file_content)
Is there any way to modify the stream (file_content) and replace lines on the fly?