[Tutor] Replacement for __del__
spir
denis.spir at free.fr
Tue May 19 11:55:49 CEST 2009
Le Tue, 19 May 2009 09:12:34 +0200,
"A.T.Hofkamp" <a.t.hofkamp at tue.nl> 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. 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.
If this looks you what you intend to do, then there are alternatives such as using "try...finally" to ensure cleanup (also "with"?).
Sorry if I misunderstood.
Denis
------
la vita e estrany
More information about the Tutor
mailing list