win32com: subclass a com object?

Bernhard Reiter bernhard at alpha1.csd.uwm.edu
Sun Dec 12 14:38:23 EST 1999


On Sun, 12 Dec 1999 18:29:31 GMT, tiddlerdeja at my-deja.com <tiddlerdeja at my-deja.com> wrote:
>I'm fairly new to python and am currently using it to script COM
>objects.

Welcome to the pythodome!

>I'd like to know how to subclass or derive from a existing COM object.
>This subclass would implemented as a COM object itself. The "create a
>COM object in python" I can do. It's just the inheritance I can't. I'd
>like then to override a method of the base class in the derived class.
>(I have run makepy.py over the existing/base COM object already).

Hmm. I haven't done this, but you certainly can derive from the
class, which wraps the COM object and intercept the method.

Mark can tell you more about it.
The most easiest solution would be to write your own class,
initialise instances with the original COM instance
and just imitate all methods and call the original object except of 
course for the method you want to change.

>Also, an aside question about win32com. Would someone use win32com just
>to avoid paying for a VB license to develop COM object? 
No.
>Or are there
>actual benefit to scripting COM in python? 
Yes there are actual benefits.
>Is COM simpler in python?
Yes.

I will only give you the two most obvious ones:
	- Python is Free Software and brings you more freedom as
	VB, which is proprietory. This includes a bunch of advantages.

	- You only have to learn one more powerful language, because
	python is cross platform and simple.

Bernhard

-- 
Research Assistant, Geog Dept UM-Milwaukee, USA.  (www.uwm.edu/~bernhard)
Free Software Projects and Consulting 		         (intevation.net)  
Association for a Free Informational Infrastructure            (ffii.org)



More information about the Python-list mailing list