Using Files | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Using Files

What would happen when I forgot to close a file after being used it?

14th Nov 2019, 4:06 PM
Aung Thu Win
Aung Thu Win - avatar
2 Answers
+ 9
What can happen is, that some new data you have *written* to the file are missing, when file is not closed explicitely. If you use *with ...*, files will be closed automatically. The loss of some data can happen, as the new data are first put in a cache / buffer, and then flushed to the hard drive when file is closed.
14th Nov 2019, 8:15 PM
Lothar
Lothar - avatar
+ 2
'Enter'?
14th Nov 2019, 4:18 PM
HonFu
HonFu - avatar