On Tue, May 19, 2009 at 5:55 AM, spir <[email protected]> wrote:
> Le Tue, 19 May 2009 09:12:34 +0200,
> "A.T.Hofkamp" <[email protected]> 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__, id est try to do garbage collection instead of
> letting python do it. This is for the python object side.
Correct.
> 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. I usually tell people to never supply a __del__
implementation. By the time it's executed many of the resources that
you want to clean up could have already been garbage collected. To
protect against this I see people doing things like::
def __del__(self):
try:
self.f.close()
except:
pass
To me this is just silly.
--
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor