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