[python-win32] Passing arrays by reference

Tim Roberts timr at probo.com
Wed May 20 19:27:50 CEST 2009


Benoît Prigent wrote:
> Hi all,
>
> I found a thread that it similar to what I'm looking for:
> http://mail.python.org/pipermail/python-win32/2002-November/000562.html
> but I couldn't come up with a solution...
>
> I have a C++ server with a COM interface, which I can access via JScript
> without any problem, but when it comes to Python, it seems impossible to
> pass an array from the server to the Python script by reference.

Right. There is just no way to do that in Python.  Thus, [out]
parameters are generally returned to you as outputs from the function. 
I'm guessing you need something like this:

    ans = [1,2,3]
    (rc,ans) = Server.EchoArray([0x11,0x22,0x33])
    print ans

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



More information about the python-win32 mailing list