473,785 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Optional Parameters in python COM

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.Sessio n.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.Missi ng and
pythoncom.Empty for the non essential parameter. I have also edited the
generated .py file so that it contains the following:

defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty

But this has not made any difference! Any help would be very much
appreciated.

Cheers,

Rane
Jul 18 '05 #1
3 4343
<bump>

"Rane Bowen" <ra***@slingsho t.co.nz> wrote in message
news:bv******** **@lust.ihug.co .nz...
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.Sessio n.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.Missi ng and
pythoncom.Empty for the non essential parameter. I have also edited the
generated .py file so that it contains the following:

defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty

But this has not made any difference! Any help would be very much
appreciated.

Cheers,

Rane

Jul 18 '05 #2
<grind>
"Rane Bowen" <ra***@slingsho t.co.nz> wrote in message
news:bv******** **@lust.ihug.co .nz...
<bump>

"Rane Bowen" <ra***@slingsho t.co.nz> wrote in message
news:bv******** **@lust.ihug.co .nz...
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.Sessio n.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.Missi ng and
pythoncom.Empty for the non essential parameter. I have also edited the
generated .py file so that it contains the following:

defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty

But this has not made any difference! Any help would be very much
appreciated.

Cheers,

Rane


Jul 18 '05 #3
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.Sessio n.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.Missi ng and
pythoncom.Empty for the non essential parameter. I have also edited the
generated .py file so that it contains the following:

defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty

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.

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1462
by: Philip Rittenhouse | last post by:
I have discovered a couple of problems with the way the universal gateway code handles optional parameters and variable argument lists in COM servers. It appears to only be a problem when you use the custom interface. What I found was that variable argument lists are not detected at all. Instead they are just converted from SAFEARRAYs to a Python list.
13
2517
by: William Ryan | last post by:
I just picked up a copy of John Robbins' debugging book and started to look at disassembled code. Anyway, I hate optional Parameters in VB, but I was checking them out to see what IL is created. I've done this before with Modules, and saw that <gasp> they behave just like sealed classes with only static members. Anyway, it looks like Optional Parameters are nothing but a way to tell the compiler to write some overloads for you. So, in...
16
4064
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
14
3275
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To make things simpler and better readable I'd make all default parameters named parameters so that you can decide for yourself which one to pass and which not, rather than relying on massively overlaoded methods which hopefully provide the best...
5
1410
by: Miro | last post by:
This qustion is probably for people who have created large apps with subs / or functions that have a lot of parameters and used in a lot of places in ur whole app. ( lets say its ur own library function ) -Not looking for a big complicated question... ( dont waste a lot of ur time please ) I have been searching for the "Optional" parameter forever in VB.net I have found a pretty down to earth article on why NOT to use them....
12
2674
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be avoided. I'd like to hear your various opinions on this matter.
1
8419
by: peridian | last post by:
This is more of a general question, but I didn't know where to post it. Since Java is an example of a language which does this, I thought here would work. Coming from a C++ background, having used VBA/VB6 quite a bit, and a number of scripting languages with similar traits, like php, I had grown accustomed to optional parameters in my functions. I recently found out that certain modern languages do not support these, namely Java and...
1
1320
by: MisterWilliam | last post by:
I noticed that in PEP 3105, the PEP about turning print to print(), the syntax for print() is defined as follows: def print(*args, sep=' ', end='\n', file=None) Ignoring the fact that print is a reserved keyword in python, this is not valid python because extra positional arguments (*args), cannot come before optional parameters (sep=' ', end='\n', file=None). File "<stdin>", line 1 def f(*args, sep=' ', end='\n', file=None):
7
7070
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1 As Integer = 0, _ Optional ByVal Arg2 As Integer = 0, _ Optional ByVal Arg3 As Integer = 0) ' Call my SQL proc with the same signature
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.