FAQ: how to vary the byte offset of a field of a ctypes.Structure

p.lavarre at ieee.org p.lavarre at ieee.org
Sat Jun 2 03:03:50 CEST 2007

> Often it helps to ask yourself the question: How would I do this in C? ...
> *Not* by using a structure. A structure is fine if the definition is fixed,
> or at most has *one* variable sized field at the very end.

might be near where I'll find concise Python ways of pickling and
unpickling the (0xFF ** N) possible ways of packing N strings of byte
lengths of 0..xFE together ...

I notice by now I need what ctypes does well often enough that I have
to make my corrupt copy of a subset of ctypes coexist with ctypes per
se. So I have two different BYTE definitions. One is the
ctypes.c_ubyte. The other is my corrupt copy. And likewise for a big-
endian BIG_WORD and so on. So I end up naming the one BYTE and the
other BITE, the one BIG_WORD and the other BIG_WURD, yuck.

More information about the Python-list mailing list