Python COM problem - accessing properties with optional parameters
Mark Hammond
mhammond at skippinet.com.au
Fri Jun 28 20:10:29 EDT 2002
More information about the Python-list mailing list
Fri Jun 28 20:10:29 EDT 2002
- Previous message (by thread): exec, namespace, and reference count question
- Next message (by thread): Python COM problem - accessing properties with optional parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dave Kirby wrote: > I am using Python to access the Microsoft Accessibility interface. I have > got as far as getting an IAccessible object, but am having problems calling > some of its methods. > > The problem is that some of the methods are declared as properties with > [propget] or [propput] in the IDL, but also have optional parmeters. For > example: > > [hidden, propget, id(DISPID_ACC_NAME)] HRESULT accName([in, optional] > VARIANT varChild,[out, retval] BSTR* pszName); > > if I have a an object called obj I can access the property accName like > this: > > >>>>obj.accName >>> > u'Some Object Name' > > > which is all fine and good. However there are times when I need to call the > accName method with an int parameter, e.g. > > >>>>obj.accName(0) >>> > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > TypeError: object of type 'unicode' is not callable > > > this obviously doesnt work, since it treating it as a property and returning > a string, then trying to call that string as a function. If you run makepy over the type library, you *should* find that the property has *also* been exposed as a "SetAccName()" method. Check the generated code for details. Mark.
- Previous message (by thread): exec, namespace, and reference count question
- Next message (by thread): Python COM problem - accessing properties with optional parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list