win32com.client - need some help
zippy1984 at my-deja.com
zippy1984 at my-deja.com
Thu Jan 25 08:36:45 EST 2001
>
> Pretty unusual VB usage, but, yes, it does happen. It's unclear
> to me whether the single argument of method getDictionary is
> [out] or [in,out] -- presumably just [out]...? VB is often
> not crystal-clear about such things (which yet ARE crucial --
> resource leaks are possible if one gets confused) and looking
> at the IDL for the type library in question is quite a good idea
> (VB Professional, I think, comes with the "OLE Viewer" which,
> among many other precious uses, lets one look at the IDL of any
> type library; if it doesn't, then get the Platform SDK download,
> THAT one surely does come with oleview.exe and it's free, though
> rather big to get).
Here is a snip of the IDL file:
HRESULT getDictionary([out] IDispatch** pDictionary);
[id(0x12345678)]
>
> > Python:
> > import win32com.client
> > ob = win32com.client.Dispatch("some.object.1") # ok
>
> Do make sure makepy.py HAS been run on the typelibrary whence
> some.object comes from, though. To ensure that, you may use:
Here is a snip of the generated .py file:
def getDictionary(self, pDictionary=defaultNamedNotOptArg):
return self._ApplyTypes_(0x12345678, 1, (24, 0), ((16393, 2),), \
'getDictionary', None,pDictionary)
>
> Once makepy has operated on the type library, [out] arguments
> are transformed into return values, so:
>
> dic = ob.getDictionary()
>
Yes, I am able to call this way using the generated classes, and also
without... This is what happens:
>>> dic = ob.getDictionary()
>>> dic
<COMObject getDictionary>
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:
>>> 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
>>>
Not unexpected, as getDictionary does not have a getValue method....
So, what is going on here? Any idea?
I have quite a bit of experience with Python, but very little with
Windows and COM in general (and therefore win32com), so any help
is appriciated.
Tom
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list