Re: [Tutor] Replacement for __del__

2009-05-19 Thread spir
Le Tue, 19 May 2009 19:27:16 +0100, "Alan Gauld" s'exprima ainsi: > > def __del__(self): > >try: > >self.f.close() > >except: > >pass > > This is, I agree, pointless. but very different to: > > def __ del__(self): > try: > os.remove(self.lockname) > e

Re: [Tutor] Replacement for __del__

2009-05-19 Thread Alan Gauld
"David Stanek" wrote But I think (someone confirms/contradicts?) there is no harm in overloading a class's __del__ to accomplish additional tasks such as deleting temp disk space/dirs/files that need to exist only during object creation. Incorrect. Why? implementation. By the time it

Re: [Tutor] Replacement for __del__

2009-05-19 Thread David Stanek
On Tue, May 19, 2009 at 5:55 AM, spir wrote: > Le Tue, 19 May 2009 09:12:34 +0200, > "A.T.Hofkamp" s'exprima ainsi: > >> A folder is created during object instantiation. > > Do you mean a filesytem directory? I may be wrong, bit it seems there is a > bit of confusion between things and their rep

Re: [Tutor] Replacement for __del__

2009-05-19 Thread spir
Le Tue, 19 May 2009 09:12:34 +0200, "A.T.Hofkamp" s'exprima ainsi: > A folder is created during object instantiation. Do you mean a filesytem directory? I may be wrong, bit it seems there is a bit of confusion between things and their representation as python objects. You shouldn't call __del_

Re: [Tutor] Replacement for __del__

2009-05-19 Thread A.T.Hofkamp
Strax-Haber, Matthew (LARC-D320) wrote: A folder is created during object instantiation. This is necessary because multiple other methods depend on the existence of that folder, and in the future things may be running in parallel so it has to be there for the entire life of the object. Before the

Re: [Tutor] Replacement for __del__

2009-05-18 Thread wesley chun
> I've been told numerous times that using __del__ is not the way to handle > clean-up because it is finicky. matthew, welcome to Python and this Tutor mailing list! and yes, i'll echo everyone else in saqying that using __del__ should be avoided. the most critical issues regarding this is becau

Re: [Tutor] Replacement for __del__

2009-05-18 Thread Alan Gauld
"Strax-Haber, Matthew (LARC-D320)" wrote My class sub-types dict. In __init__, there is a call to self.update(pickle.load()). For some reason, this triggers __del__. Why? A pure guess, but maybe the pickle load creates a new instance which replaces the original which then gets garbage col

[Tutor] Replacement for __del__

2009-05-18 Thread Strax-Haber, Matthew (LARC-D320)
To all the generous Python coders on this list, I've been told numerous times that using __del__ is not the way to handle clean-up because it is finicky. Fine. However, how should I handle the following problem: A folder is created during object instantiation. This is necessary because multiple ot