473,624 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("myfi eld")
setter obj.Value("myfi eld") = newvalue

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

However the set value fails (unsurprisingly )
>>comp.value("P hone1") = "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 1487
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("myfi eld")
setter obj.Value("myfi eld") = 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("Pho ne1")
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("myfi eld", "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("m yfield", "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.quel quepart.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("myfi eld")
setter obj.Value("myfi eld") = 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("Pho ne1")
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
1861
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 message is all about. Any ideas? error: invalid initialization of non-const reference of
4
1365
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 XMLVALIDATINGREADER? I am getting an invalid cast. It seems that although the XSLTRANSFORM 'transform' method does return a XMLREADER object and you can work with that, you can not pass it
20
1876
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) here is a sample program I am using to test the algorythm. ----- start main.c -----
9
1648
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
1646
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 myVal);
3
1543
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
1854
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 behavior with the overloaded Property Offsets: In class CanvasBlock: ------------------------------ Public Enum EOffsetTypes
0
1001
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
1901
by: yatuo-kui | last post by:
the strange accident http://www.hotalways.com/groups/viewthread.php?tid=12&extra=page%3D1
0
8249
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
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,...
1
6112
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
5570
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
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.