win32com.client - need some help

Mark Hammond MarkH at ActiveState.com
Thu Jan 25 12:45:53 EST 2001


In article <94pa5c$aqb$1 at nnrp1.deja.com>,
  zippy1984 at my-deja.com wrote:

>    HRESULT getDictionary([out] IDispatch** pDictionary);
>    [id(0x12345678)]

...
> >>> dic = ob.getDictionary()
> >>> dic
> <COMObject getDictionary>

There are 2 reasons this is happening.  If the IDL correctly
said "IDictionary" instead of IDispatch, _or_ the IDictionary
implementation of IDispatch supports type info, then makepy would know
exactly what the object is.

However, as neither of these are true, Python knows nothing more than
it is an IDispatch.

>
> I find this strange...getDictionary is just the method, in VB I here
> get an instance of the IDictionary, which has the getValue method
> I need (IDictionary is a subclass of IDispatch).  This is what
> happens now:

This is win32com mis-leading you.  It tries to use the "name" of the
object, and without any type information or other hints, it uses the
name of the method or property.  This often works quite well - eg, if
instead of a method called "getDictionary" it was simply a property
named "dictionary" it would make much more sense.

> >>> val = dic.getValue('Version')
> Traceback (innermost last):
>   File "<interactive input>", line 1, in ?
>   File "C:\Python20\win32com\client\dynamic.py", line 435, in
> __getattr__
>     raise AttributeError, "%s.%s", % (self._username_, attr)
> AttributeError: getDictionary.getValue
> >>>

I have no idea why this is failing.

Mark.


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list