does python have useless destructors?

Michael Hudson mwh at python.net
Thu Jun 17 11:13:38 CEST 2004


Donn Cave <donn at u.washington.edu> writes:

> In article <m3fz8xozi1.fsf at pc150.maths.bris.ac.uk>,
>  Michael Hudson <mwh at python.net> wrote:
> > Manlio Perillo <NOmanlio_perilloSPAM at libero.it> writes:
> ...
> > > Since __del__ isn't really 'useful', *maybe* a better solution is to
> > > add another special method for classes, ad example a __finalize__
> > > method.
> > 
> > Yes!  I'm not sure __finalize__ is really the best name, but that's
> > for another day.
> 
> Couldn't the name be __del__?  

As I think I said in one of the emails in the thread linked to from
PEP 310, life would be much easier if it wasn't.

> Given the opportunity to have both, and the assurance that
> __finalize__ will be called and __del__ might not, what
> functionality would you leave in __del__?

None at all!  This is my cunning plan...

> > I would urge everyone participating in this thread to read PEP 310,
> > the email conversation linked therein and (optional) *understand* it.
> 
> It seems to be superficially similar to finalization, 

OK, I've found this thread pretty hard to follow.  What is
"finalization" in context?

> but so constrained that it's architecturally inconsequential - I
> mean, it's by definition interchangeable with a try/finally
> construct, so there isn't any potential code architecture where you
> can say `couldn't do this without with'.

Indeed.

Cheers,
mwh

-- 
  same software, different verbosity settings (this one goes to
  eleven)                             -- the effbot on the martellibot



More information about the Python-list mailing list