On Nov 21, 2008, at 10:26 AM, MRAB wrote:

The file will be closed automatically when the file object is garbage-collected.

CPython uses reference-counting, so the file object is garbage- collected as soon as there are no references to it.

Jython (and IronPython?) are garbage-collected in the background, so the file object is garbage-collected at some point (and you don't know when that will be!) when there are no longer any references to it.

Thanks all for this clarification. That is an important distinction. (REALbasic uses reference-counting, so you can guarantee that the file will be closed as soon as it loses its last reference, but I see that we shouldn't count on that in the Python world.)

Best,
- Joe

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to