What will happened if we write 2 times file.close() statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What will happened if we write 2 times file.close() statement?

29th Mar 2016, 3:45 PM
Dinesh Ingole
Dinesh Ingole - avatar
5 Answers
+ 3
Just try it and you will know what will happen!
22nd Jun 2016, 11:26 AM
曾乐成
曾乐成 - avatar
+ 3
There whould be an error, because when you close file the object associated with this file will be deleted from memory. The second call of file.close will result in error: object file does not exist.
2nd Jul 2016, 9:05 AM
Алексей Клочков
Алексей Клочков - avatar
+ 2
I do not think that anything wrong would happen. As the file is already closed, the close() statement will not do anything.
23rd May 2016, 10:35 AM
James Flanders
0
i think its better you try ut yourself when statement is work in a single pharntases why u close it twise
13th Jun 2016, 10:28 AM
Iman Ali
Iman Ali - avatar
0
Either nothing or it'll return an error, try it yourself to know for sure or check documentation
1st Jul 2016, 8:58 PM
Azriel Gridfen
Azriel Gridfen - avatar