CTYPES structure passing
Bryan
bryanjugglercryptographer at yahoo.com
Thu Jun 3 22:54:35 EDT 2010
Correction/addendum: I wrote:
> try to to
> be to upset when you find out how your three days were wasted...
Of course that's, "try not to be too upset..."
[...]
> You're probably familiar with the Python
> convention of special member names with double-underscores at each
> end? Well, ctypes doesn't follow it.
The double-ended-double-underscore convention is for names defined by
the Python language. As a library module, ctypes is technically right
not to use it. It's still a diabolical gotcha.
[...]
> If you spell _fields_ as ctypes
> requires, it will complain about your assignments, in that you are
> trying to assign an in to a union.
Obviously a typo, for "trying to assign an int to a union." Come to
think of it, I bet initially Peter West had that bit right. Because of
the _fields_ issue, the correct assignment failed:
FrameFormat.XUnion.subSample = 0
Without _fields_, ctypes did not create a FrameFormat.XUnion member,
so the assignment fails with "AttributeError: 'LUCAM_FRAME_FORMAT'
object has no attribute 'XUnion'".
--
--Bryan Olson
More information about the Python-list
mailing list