Interconvert a ctypes.Structure to/from a binary string?

Uwe Schmitt rocksportrocker at
Sat Aug 2 13:07:35 CEST 2008

On 2 Aug., 08:35, Andrew Lentvorski <bs... at> wrote:
> Basically, I'd like to use the ctypes module as a much more descriptive
> "struct" module.
> Is there a way to take a ctypes.Structure-based class and convert it
> to/from a binary string?
> Thanks,
> -a

My first idea was :

   from ctypes import *
   from pickle import *

   class T(Structure): pass

   print dumps(T())

which raises an TypeError, "abstract class".

And then I found

Greetings, Uwe

More information about the Python-list mailing list