win32com.client genpy support

Mark Hammond mhammond at skippinet.com.au
Sun Dec 15 17:49:32 EST 2002


Syver Enstad wrote:
> Sometimes when I do variable.__class__ on COM object I find that it's
> class is the coclass wrapper. 
> 
> Example:
> 
> word = win32com.client.Dispatch('Word.Application')
> 
> # word is of class _Application which it should be
> 
> document = word.Documents.Add()
> 
> # document is of class Document which is derived from CoClassBaseClass
> # but it responds to the right methods anyway.
> 
> What is going on? Is this right?

Yes, this is right.  It is a by-product of how CoClasses work.  The 
CoClass for an object describes the events, and possibly multiple 
interfaces supported by the object.

I could avoid this, but don't see a need as it works just fine.

Mark.





More information about the Python-list mailing list