[issue10093] Warn when files are not explicitly closed
R. David Murray
report at bugs.python.org
Sat Oct 30 18:29:38 CEST 2010
R. David Murray <rdmurray at bitdance.com> added the comment:
MAL wrote:
> Antoine wrote:
>> MAL wrote:
>>> I don't follow you. Where's the difference between writing:
>>>
>>> s.close()
>>> or
>>> s = None
>>>
>>> for an open socket s ?
>>
>> The difference is when s is still referenced elsewhere.
>> Also, the intent of the former is clear while the latter is deliberately
>> obscure (while not saving any significant amount of typing).
>
>Sure, but that's not the point. It is not a mistake to write
>such code and neither is this obscure, otherwise we'd also
>require explicit garbage collection for other parts of Python.
Yes it is a mistake:
In an earlier message MAL wrote:
> The only difference is with Python implementations that don't
> use synchronous garbage collection, e.g. Jython, but not with
> CPython.
This by definition makes it non-equivalent and a bad *Python* idiom,
since it depends on an acknowledged CPython *implementation detail*.
As far as I know, there is no language requirement that mandates having
garbage collection at all.
----------
nosy: +r.david.murray
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10093>
_______________________________________
More information about the Python-bugs-list
mailing list