So I'm learning about reading and writing from file in python. I seem to understand that if you use 'w' in order to open an existing file for writing, it will overwrite that file. So right now, I am doing something like this:
with open('something.json', 'r') as open_file:
get some stuff
with open('something.json', 'w') as open_file:
add some stuff
Is it normal to open and close the file twice in order to both read and write, or is there an optional argument that might allow me to do everything all at once?