Message 120000 - Python tracker (original) (raw)

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.