pywin32/win32com float/double coercion

mazerj2006 at gmail.com mazerj2006 at gmail.com
Mon Oct 1 16:42:24 EDT 2007


I'm an old hand at python, but totally new to win32com -- I've run
into a snag that seems to be related to python's (usually handy) lack
of
distinction between floats and doubles. Can anyone explain to me (or
point me towards the right docs) how the win32com module handles an
ActiveX component that returns or expects an array of SINGLE precision
floats (ie, 32-bit floats)?

I'm using a vendor-supplied ActiveX component with two related API
calls that use variant arrays:
  vector = ReadDataV(...)
  WriteDataV(vector)

ReadData() correctly returns a tuple of floats when called from python
via win32com. However, WriteDataV() expects a vector of single
precision floats, but it seems like the win32com coercion mechanism is
passing in doubles (or at least after a few days of banging my head
against this, I'm convinced that's what's going on).

Basically the following results in garbage getting sent to the
component:
  x = ReadDataV()
  WriteData(x)

Can anyone point me in the right direction for fixing this problem? Is
there a way to force win32com to use single precision when passing in
floating point arrays?

Thanks,
/jamie

(please CC me a copy of any replies -- I'm WAY behind on c.l.p.)




More information about the Python-list mailing list