[python-win32] Importing an array from COM into Python

Metz, Bobby W, WCS bwmetz at att.com
Tue Apr 4 22:46:32 CEST 2006


Not sure about your COM issue, but assuming Google hits all the archive
pages like I think it does, just use "site:mail.python.org" on the end
of your search string.

Bobby

-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Dana Robinson
Sent: Tuesday, April 04, 2006 12:15 PM
To: python-win32 at python.org
Subject: [python-win32] Importing an array from COM into Python


Hello,

I am trying to get the arrays out of this function (from the IDL):

[id(175), helpstring("method CreateFooBarArray")] HRESULT
CreateFooBarArray([out]DOUBLE** FooArray, [out] DOUBLE** BarArray,
[out,retval] ULONG* SizeOfFooBarArrays);

The two arrays (Foo and Bar) are created with malloc and filled with
useful data inside the COM object.

I am attempting to access them with the following Python code.

size = o.CreateFooBarArray(fooArray, barArray)

This does not work.  I get an error in \client\__init__.py at line 447
in
_ApplyTypes_.  It says "float() argument must be a string or number"
Other COM functions with simple types work fine.  I ran makepy.py over
the
COM library and I'm using early-bound automation if that makes any
difference.

So I have two questions:

1) The COM object is brand new and created in-house so I can have it
changed to my liking.  What's the best way to pass a large array
(thousands of elements) of doubles out of a COM object into Python?  I
have Mark Hammond's book, which is very helpful, but passing arrays
between languages doesn't seem to be covered.

2) If the COM object handles the memory allocation, will the arrays be
properly garbage collected?

Actually, I have a third question.  Where can I find a searchable
version
of the mailing list?  The one at python.org doesn't appear to be
searchable.

Thanks for your help.  I just switched from the digest to individual
mails, so if you respond this afternoon please cc me so I'll be able to
try your suggestions out before I go home.

Thanks,

Dana Robinson
_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


More information about the Python-win32 mailing list