COM interfaces and inheritance

Mark Hammond mhammond at skippinet.com.au
Tue Nov 19 16:56:55 EST 2002


Alan Kennedy wrote:

> So some code might look like this
> 
> objA = createObjA() # Returned object implements interface A
> objB = myModule.IInterface2(objA)
> # Bingo!
> 
> At least, that works for me :-)
> 
> I hope this helps, and that I've explained it clearly enough.

The next version of win32all will have win32com.client.CastTo() - then 
you can simply give the interface by name.  Eg, the SpamBayes outlook 
addin uses this now:

popup = CastTo(popup, "CommandBarPopup")

To "cast" a "CommandBar" object to "CommandBarPopup" (where the latter 
derives from the former).

Mark.




More information about the Python-list mailing list