Passing a Com Object as an argument
Mark Hammond
mhammond at skippinet.com.au
Mon May 27 19:20:15 EDT 2002
Zsolt Marx wrote:
> Hi there. I am using Python on Win32. I have just managed to
> utilitze COM Objects in Python using the win32all package.
>
> Here's my question: How can I define a Python function having a COM
> interface or a COM class as an argument?
>
> Thanks in advance
In general, you don't need to do anything - the code calling your object
can simply pass a COM object, and your Python code will get it.
However, you will generally get a "raw" dispatch pointer. You generally
want to wrap it up in a nice Dispatch object. Something like:
def foo(self, bar):
# bar is a "<PyIDispatch object at xxx>"
bar = win32com.client.Dispatch(bar) # Now a usable object
Mark.
More information about the Python-list
mailing list