win32com: subclass a com object?

Mark Hammond mhammond at skippinet.com.au
Mon Dec 13 18:10:55 EST 1999


tiddlerdeja at my-deja.com wrote in message <832skg$4bn$1 at nnrp1.deja.com>...

>Roughly speaking, for COM object:
>
>class foo:
>    def bar():
>        # do something
>    def x():
>        # blah
>    def y():
>        # blaah
>
>If I want to create myFoo by inheriting from foo. I want to override
>the method bar in the derived class. Can I just do:
>
>class myFoo(foo):
>    def bar():
>        # myBar

Yes - you can do this - but only for your own Python code - there is no
reasonable way to setup COM so that anyone else (ie, other languages and
programmers) can create an "Excel.Application" object and have it use yours.
It _would_ be basically possible to have it work with "MyExcel.Application".

My earlier post in this thread showed how to do it for your own Python app.
Allowing it to work for other apps is more difficult, but I doubt that is
what you are after...

Mark.






More information about the Python-list mailing list