[python-win32] Problem: methods defined in type library's base class are not accessible in inherited class objects of the type library

Indranil Sinharoy indranil_leo at yahoo.com
Thu Feb 18 18:36:37 EST 2016


Hi all,

I am a relatively new user of pywin32 package, but not Python. I have an 
application (written in C/#, as I understand) that provides a COM 
interface for using with other languages such as Python. I am using the 
pywin32 library to communicate with the application and it works fairly 
well. However, I am facing a particular kind of problem. The problem is 
that the application exposes some interface objects that inherit from 
other base objects but the methods defined in the base class objects 
doesn't seem to be accessible to the child class object. Is this type of 
behavior is atypical with pywin32? If so, what is the recommended way of 
addressing this problem? Currently, I am patching these methods in the 
child class object and delegating the calls to the parent object (using 
CastTo)) as shown in the pseudo-code below:

class MyBaseClass:
     ...
     ...
     def my_parent_method(self):
         base = win32com.client.CastTo(self, 'MyParentClass')
         return base.my_parent_method()
     ...


Although this strategy works, I would like to find out if there is a 
more efficient/ automatic way of resolving this  issue.  In my 
particular case, there are a large number of such objects (that inherit 
from some base class without access to the methods defined in the parent 
class) provided by the application and I would like to avoid re-writing 
all the methods for all such objects.

I hope I have been able to explain my problem well.

Thank you very much,
Best regards,
Indranil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20160218/206f14fe/attachment.html>


More information about the python-win32 mailing list