win32com: subclass a com object?

Bernhard Reiter bernhard at alpha1.csd.uwm.edu
Mon Dec 13 12:53:02 EST 1999


On Sun, 12 Dec 1999 23:43:58 GMT, tiddlerdeja at my-deja.com <tiddlerdeja at my-deja.com> wrote:
>In article <slrn857udf.dqp.bernhard at alpha1.csd.uwm.edu>,
>  bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) wrote:
>> On Sun, 12 Dec 1999 18:29:31 GMT, tiddlerdeja at my-deja.com
><tiddlerdeja at my-deja.com> wrote:
>

>> >I'd like to know how to subclass or derive from a existing COM object.

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

>I know I'm being pretty lame, but could you give me an example? Even for
>say MS Word?

As Mark pointed out the other way and I am quite busy right now, please
take my appologies for not being more specific.

>I know about python inheritance (I should have made this clear in the
>original message).
>Perhaps my lack of understanding is the COM/python integration. With COM
>you use the Dispatch method to create an instance. If you create a
>python subclass, e.g.:
>
Something along these lines:

>class myMSWord(MSWord):
	def __init__...
		self.realcomobject= Dispatch("...)

	def __del__...
		self.realcomobject.Quit()


	def __getattr__(self, name)...

-- 
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