COM interfaces and inheritance

Rob Sykes Robert_NJ_Sykes at msn.co.uk
Tue Nov 19 04:27:07 EST 2002


Hi all,

I'm having a problem with a (3rd party) IDispatch interface

The problem can be summarised thus: I have two classes, one
inheriting from the other.

class foo():
    	pass

class bar(foo):
    	self.stuff = 7


I need to create a new bar object but the 3rd party interface gives
me a method which returns foo objects

newBar = CreateFoo() # newBar should be a bar but CreateFoo returns
                     # a foo

I'm struggling with the upcasting(?) - in Delphi there is

newBar := CreateFoo() as bar

What is the Python equivalent ?

Cheers

-- 
Rob Sykes 

Born again Bairn                  | 'The despair I can live with.
rob at john-richard dot co dot uk |  It's the hope I can't stand'
(header email for spambots)       |  (Anon.)



More information about the Python-list mailing list