[python-win32] "Casting" COM objects

Paul Prescod paul@prescod.net
Wed, 02 Apr 2003 18:13:36 -0800


Jens B. Jorgensen wrote:
> Based on the fact that makepy does its work by looking through type 
> libraries it would be possible for it to generate the type traversal 
> mechanisms you speak of, but unfortunately (or fortunately?) it doesn't 
> as far as I know.

I was thinking more of a feature I could call explicitly at runtime than 
something baked into the interfaces, rather than a new feature for makepy.

> ... casting" the type by passing the python object reference you 
> have to the constructor of the object wrapping the interface you want is 
> the method that I use.

The problem is it can be inconvienent or impossible to figure out what 
constructor is appropriate. I'm thinking of something more dynamic where 
I don't tell it what to do, I just tell it: "figure out what class you are."

  Paul Prescod