473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Strange method signature via COM

We are trying to use the API of a Win32 app which presents the API as a COM
interface. The sample VB code for getting and setting the values of custom
data fields on an object shows a method named Value():

getter obj.Value("myfield")
setter obj.Value("myfield") = newvalue

Using Python 2.5 and PythonWin we can get data from data fields using the
identical syntax
>>print comp.Value("Phone1")
99080980

However the set value fails (unsurprisingly)
>>comp.value("Phone1") = "6876876876"
SyntaxError: can't assign to function call

Does anyone have any idea how to use Python to address this type of method
signature? Would MakePy allow us to see how we should be calling it?

All suggestions welcome!

Mar 2 '07 #1
2 1477
Richard Jebb a écrit :
We are trying to use the API of a Win32 app which presents the API as a COM
interface. The sample VB code for getting and setting the values of custom
data fields on an object shows a method named Value():

getter obj.Value("myfield")
setter obj.Value("myfield") = newvalue

Using Python 2.5 and PythonWin we can get data from data fields using the
identical syntax
I have no experience with Python/COM, but IIRC, in VB (at least in VB6),
the parens are also used for array subscript.
>
>>>>print comp.Value("Phone1")
99080980

However the set value fails (unsurprisingly)

>>>>comp.value("Phone1") = "6876876876"

SyntaxError: can't assign to function call

Does anyone have any idea how to use Python to address this type of method
signature?
Have you tried inspecting your COM object in an interactive Python
shell, using dir(), help() and the inspect module ?

And FWIW, disd you try the following syntaxes:
comp.value['Phone1'] = "xxx"
comp['Phone1'] = "xxx"

My 2 cents
Mar 2 '07 #2
After digging around in the group archives I've figured it out. It's not
been helped by my inability to identify the API's COM server/type library in
the list produced by the MakePy utility, so I've largely been flying blind.

Some posts on this same subject back in 1999 revealed the answer, namely
that when win32com encounters a method signature like the one we had, it
expects you to call it like this:

obj.Value("myfield", "newvalue")

If there already exists an interface to Value() with this signature, then it
prepends the original method name with "Set", so that in Python you would
call

obj.SetValue("myfield", "newvalue")

We still have some other issues with the API, but I'm hoping once the
application vendor has revealed what name it will appear under in MakePy we
will be able to sort those out as well.
"Bruno Desthuilliers" <bd*****************@free.quelquepart.frwrote in
message news:45**********************@news.free.fr...
Richard Jebb a écrit :
We are trying to use the API of a Win32 app which presents the API as a
COM
interface. The sample VB code for getting and setting the values of
custom
data fields on an object shows a method named Value():

getter obj.Value("myfield")
setter obj.Value("myfield") = newvalue

Using Python 2.5 and PythonWin we can get data from data fields using
the
identical syntax

I have no experience with Python/COM, but IIRC, in VB (at least in VB6),
the parens are also used for array subscript.
>>>print comp.Value("Phone1")
99080980

However the set value fails (unsurprisingly)

>>>comp.value("Phone1") = "6876876876"
SyntaxError: can't assign to function call

Does anyone have any idea how to use Python to address this type of
method
signature?

Have you tried inspecting your COM object in an interactive Python
shell, using dir(), help() and the inspect module ?

And FWIW, disd you try the following syntaxes:
comp.value['Phone1'] = "xxx"
comp['Phone1'] = "xxx"

My 2 cents

Mar 2 '07 #3

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

Similar topics

13
by: Neil Zanella | last post by:
Hello, I wonder whether anyone has ever come across the following g++ compiler error message. I don't recall ever seeing it before. I solved my problem but I am still not sure about what this...
4
by: badbetty | last post by:
Hello and thank you for reading on (hopefully). How does one typecast the XMLREADER returned from the XSLTRANSFORM method 'transform' into XMLTEXTREADER, so it can be passed in to an...
20
by: Materialised | last post by:
Hi Everyone, I am having a few issues while attempting to use Kevin Easton's base64 encryption algorythm. (See http://groups.google.com/groups?selm=ahr1ji%246v3%241%40tomato.pcug.org.au) ...
9
by: Karahan Celikel | last post by:
Here are three simple classes: class A { public void DoIt(B b) { DoSomething(b); } public void DoSomething(B b) {
0
by: Cordell Lawrence | last post by:
Okay guys, We are wondering if this is a bug in Framework 2.0.40607 and looking for some clarification on the issue. Take a look at the folowing code. public delegate bool BoundryTest(int...
3
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
3
by: Arnold Schrijver | last post by:
I wrote a program that draws items to the screen and maintains a set of Offset values. There was a bug in the code, because objects were positioned wrongly. While debugging I found some peculiar...
0
by: M.Posseth | last post by:
Hello , I have a strange problem when i set a reference to http://www.trostonline.de/autobest/tolwebservice.dll/wsdl/ITOLServiceInterface i end up with a logon method like this
22
by: yatuo-kui | last post by:
the strange accident http://www.hotalways.com/groups/viewthread.php?tid=12&extra=page%3D1
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.