win32com: subclass a com object?

tiddlerdeja at my-deja.com tiddlerdeja at my-deja.com
Sun Dec 12 19:05:14 EST 1999


In article <mBV44.5892$Cl3.34862 at news-server.bigpond.net.au>,
  "Mark Hammond" <mhammond at skippinet.com.au> wrote:

> Another reply suggested using delegation - ie, create a completely
seperate
> class, and have it hold the "real" COM object.  This is a good
suggestion.
>
Thanks for this. The thought had crossed my mind to use delegation, but
that would not follow the "isa" inheritence model I'd like to use.

I'll try your code below too as it looks like what I'm after.

Thanks for your help.

> However, to implement sub-classing you can do the following:
> >>> klass =
win32com.client.gencache.GetClassForProgId("Excel.Application")
> >>> if klass is None: raise RuntimeError, "Please run makepy for this
> object."
> >>> class MyExcel(klass):
> ...    pass
>
> Mark.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list