Best way to disconnect from ldap?

Terry Reedy tjreedy at udel.edu
Thu Mar 22 15:27:37 EDT 2012


On 3/22/2012 1:54 PM, Tim Chase wrote:
> On 03/22/12 12:26, Steven D'Aprano wrote:
>> On Thu, 22 Mar 2012 08:14:47 -0500, Tycho Andersen wrote:
>>> Given that you can't trust __del__, is there a legitimate
>>> use case for it?

It is part of original or early Python and pretty well superceded by 
cyclic gc (which does not work for object with __del__ *because* of the 
unreliability), explicit close methods, and now context managers.
>>
>> I've never found the need to write one.
>
> I've found the need to write them...then been frustrated by things
> falling out of namespace reach, and found that context managers do a
> much more reliable/understandable job, saving what little sanity I had
> left. ;-)

Which is one reason they were added ;-).

> So I'd say that __del__ was really only useful (for some sick, sick
> definition of "useful") in versions of Python before context-managers
> were readily available.

And before cyclic gc, which does a better job of ordering deletions.

-- 
Terry Jan Reedy




More information about the Python-list mailing list