"Giovanni Bajo" <[EMAIL PROTECTED]> writes:
> 1) There's a way to destruct the handle BEFORE __del__ is called,
> which would require killing the weakref / deregistering the
> finalization hook.
Weakrefs should have a method which runs their callback and
unregisters them.
> 2) The objects required in the destructor can be mutated / changed
> during the lifetime of the instance. For instance, a class that
> wraps Win32 FindFirstFirst/FindFirstNext and support transparent
> directory recursion needs something similar.
Listing files with transparent directory recursion can be implemented
in terms of listing files of a given directory, such that a finalizer
is only used with the low level object.
> Another example is a class which creates named temporary files
> and needs to remove them on finalization. It might need to create
> several different temporary files (say, self.handle is the filename
> in that case)[1], so the filename needed in the destructor changes
> during the lifetime of the instance.
Again: move the finalizer to a single temporary file object, and refer
to such object instead of a raw handle.
--
__("< Marcin Kowalczyk
\__/ [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com