If I want to write data to a file using json library, Is it ok if I do this?:
...
json.dump(my_data, open('my_file_path', 'w+'))
...
Or do I have to do this?:
...
with open('my_file_path', 'w+') as my_file:
json.dump(my_data, my_file)
...
Does the first option also closes the file immediatly?