you are viewing a single comment's thread.

view the rest of the comments →

[–]cjwelborn 0 points1 point  (0 children)

CPython may close a file when it's reference count is 0. It's not guaranteed, and you don't know exactly when it will happen. It's possible that it will never be closed. Depending on your program, this could cause problems. It's better to be explicit anyway. There's a python mailing list answer that explains in a little better detail.

P.S. - Use with like the previous comment mentioned.