Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Python release file handles after calling file.close()?

Tags:

python

I am on windows with Python 2.5. I have an open file for writing. I write some data. Call file close. When I try to delete the file from the folder using Windows Explorer, it errors, saying that a process still holds a handle to the file.

If I shutdown python, and try again, it succeeds.

like image 627
ApplePieIsGood Avatar asked Feb 22 '09 15:02

ApplePieIsGood


1 Answers

It does close them. Are you sure f.close() is getting called? I just tested the same scenario and windows deletes the file for me.

like image 171
Carlos A. Ibarra Avatar answered Nov 14 '22 23:11

Carlos A. Ibarra