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" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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
-- http://mail.python.org/mailman/listinfo/python-list