Lists of lists over COM, how?

Mark Hammond mhammond at skippinet.com.au
Tue Dec 14 08:07:33 EST 1999


Alex Martelli wrote in message
<6D8A17398E28D3119F860090274DD7DB4B3D30 at pces.cadlab.it>...
>Martin writes:
>
>> I'd like to return a set of database records to Python in a single
>> variable
>> from a COM object in C++ and had hoped I could use a two-dimensional
>> VARIANT
>> array for this. Looking through the SafeArray* functions in the WIN API
>> they
>> only allow arrays of a single basic type. I had hoped that a list of
lists
>>
>Yep, but the basic type can be VARIANT -- and, inside a VARIANT,
>among other things, you can stuff other (so-called SAFE-:-)ARRAYs,
>so you can do complicated stuff if you wish:-).  But, in fact...:

Actually, SAFEARRAYs can be fully multi-dimensional - and Python supports
them - except that in Python, each dimension must be the same size - ie, you
must use a "square" sequence of sequences (of sequences ...).  Which is fine
for the intended application (and for most :-)

Although if you are exposing this as a COM object, you could consider
defining and using a "record" object...

Mark.






More information about the Python-list mailing list