win32com and parameters on property "put" methods

David Bolen db3l at fitlinxx.com
Tue Jan 22 04:24:36 CET 2002


A co-worker has been writing some Python code to use some internal COM
objects (in C++) that he had previously developed, and ran into a
problem scenario using some of his properties.

He's got some properties where the "put" method for that property
takes additional parameters beyond just the new value for the
property.

Not being intimately familiar with such beasts, I have no idea if
that's a good thing to do or something generally supported by other
languages (in C++ you just call the method directly so it clearly
works there), but he indicated that to support it in VB, you could do
something like:

    print msfStack.PlateValue(3)
     7000 
    msfStack.PlateValue(3) = 6000
    print msfStack.PlateValue(3)
     6000 

where msfStack was the COM object reference, and PlateValue was a
property.  The parameterized assignment (what to my old C based mind
looks like something that can't be an lvalue) passes the (3) argument
on to the put method for that property.

>From what I can tell win32com doesn't provide any existing way to pass
in such parameters (at least not that I can see in the way put
properties are handled in DispatchBaseClass).  I'm guessing (but still
have to try) that making a call such as:

    apply(obj._oleobj_.Invoke,
          obj._prop_map_put['Property'][0] + (arg1,arg2,...))

would work, but obviously loses the simple attribute access to properties.

Does anyone know if having properties work this way in COM is even a
good idea, and/or have any better suggestions on how to handle it on
the Python side?

Thanks.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list