with open('com1', 'r') as f:

Delaney, Timothy (Tim) tdelaney at avaya.com
Mon Apr 6 20:00:09 EDT 2009


Lawrence D'Oliveiro wrote:

> In message <mailman.3332.1238914117.11746.python-list at python.org>,
> Terry Reedy wrote:
> 
>> Lawrence D'Oliveiro wrote:
>> 
>>> All Python objects are reference-counted.
>> 
>> Nope.  Only in CPython, and even that could change.
> 
> Why should it?

Because Guido has said it might some time in the future.

>>> Once the file object becomes
>>> inaccessible, it is automatically closed. Simple.
>> 
>> Even in CPython, that would not be true now is the object became
>> involved in or became a dependent of a reference cycle.
> 
> And how exactly would that happen with a file object?

Create a cycle of objects, and have one of them reference a file object.

Tim Delaney



More information about the Python-list mailing list