[Tutor] How to create array of variants?

John Fouhy john at fouhy.net
Wed Jul 9 01:52:54 CEST 2008

On 09/07/2008, Kelie <kf9150 at gmail.com> wrote:
> I think comtypes or pywin32 do take care of some conversion between Python
>  types and VB types. But they don't work with AutoCAD.

Hi Kelie,

This is a short excerpt from _Python Programming on Win32_:

"""In many cases, PythonCOM can translate between Python objects and
VARIANT structures seamlessly.  When you call a COM object and pass a
Python object, PythonCOM automatically creates a VARIANT of the right
type and passes the VARIANT to COM.
Python object type: Any other python sequence.
VARIANT type: An array of VARIANTs; each element of the sequence is
translated using this table.
In some cases, these translations aren't suitable; for example, a COM
object may be picky about the VARIANT types passed and accept only a
VT_I2 integer, not a VT_I4 integer.  This should be considered a bug
in the COM object, but it does happen.  In this case, you must use
earlybound COM by using MakePy. [...] If you can't use MakePy for your
COM object, you must get your hands dirty and use the
PyIDispatch.InvokeTypes() method manually; this is how MakePy gets the
behaviour it does.  The use of InvokeTypes() is beyond the scope of
this book."""

I think your question is beyond the scope of this mailing list :-)  I
think there's a mailing list dedicated to python on Windows; you might
do better there.

More information about the Tutor mailing list