Optional Parameters in python COM

Mark Hammond mhammond at skippinet.com.au
Tue Jan 27 17:25:01 EST 2004


Rane Bowen wrote:

> Hi,
> 
> I am using python with a makepy generated wrapper on a COM application. One
> of this object's methods has 3 parameters, two of which are optional.
> If I call the method with just the non-optional parameter, or all three
> parameters, it works.  If I call it with the first two parameters, I get the
> following error:
> 
> (-2147352567, 'Exception occurred.', (0, 'Amphora.Session.1', 'A bad
> parameter was passed to the method', None, 0, -1610547133), None)
> 
> I have tried calling the method by using the names of the optional
> parameters, and I have also tried using pythoncom.Missing and
> pythoncom.Empty for the non essential parameter.  I have also edited the
> generated .py file so that it contains the following:
> 
> defaultNamedOptArg=pythoncom.Empty
> defaultNamedNotOptArg=pythoncom.Empty
> defaultUnnamedArg=pythoncom.Empty
> 
> But this has not made any difference!  Any help would be very much
> appreciated.

Can you reproduce this problem with a "common" object, such as IE, 
MSOffice, or a trivial VB object with sourcecode?  The problem is that 
it is up to each object to implement optional params, so it is very hard 
to pinpoint bugs in win32com here.

Mark.




More information about the Python-list mailing list