Exercise idea: edit file inplace using context manager
Build a context manager, edit
such as:
with edit("my_file.txt") as ifile, ofile:
for line in ifile:
ofile.write(line.replace("a", "b"))
replaces all a
s with b
s in my_file.txt
.
Edited by Julien Palard