[python-win32] How to delete a dispatched object
Mark Hammond
mhammond at skippinet.com.au
Thu Feb 28 23:44:19 CET 2008
As soon as the last reference to the PyIDispatch object goes away, the COM
object is released. Unfortunately, neither Python nor COM offer a way to
actually destroy an object - they are both independently reference counted
so the only option available is to drop all references being held.
In Python, this means that:
ob = win32com.client.Dispatch(.)
del ob
would cause the object to die (as would assigning 'ob' to something, such as
None), but:
ob = win32com.client.Dispatch(.)
ob2 = ob
del ob
would not - nothing you can do to 'ob' can help you now - you must also
remove the reference in 'ob2'
Mark
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Chen
Sent: Friday, 29 February 2008 2:13 AM
To: python-win32 at python.org
Subject: [python-win32] How to delete a dispatched object
Hi
I am wondering how could I delete an dispatched object? Do I just delete the
reference to that object? Does python garbage collector take care of
everything after I delete the reference? Is there any method which I could
use to delete a dispatched object?
--
CHEN HUANG
COMPUTER Engineering
McMaster University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080229/06492078/attachment-0001.htm
More information about the python-win32
mailing list