[python-win32] Problem passing array by reference

Tim Roberts timr at probo.com
Thu Jul 17 19:36:32 CEST 2014


Marco Nawijn wrote:
>
> I am facing a problem passing an array by reference. It is exactly the 
> same problem as described in this thread:
>
> https://mail.python.org/pipermail/python-win32/2002-November/000562.html
>
> In short, I have a valid reference to a Position object. This object
> has two methods,
> GetComponents and SetComponents that each take a CATSafeArrayVariant as 
> an argument. This CATSafeArrayVariant should in this case be a
> one-dimensional
> array of real values.

If these are declared correctly in their type library, then the array
should be an output value, and Python's machinery knows how to handle
that.  So:

    hr, bfr = obj.GetComponents()
    hr = obj.SetComponents(bfr)

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list