(from stdlib-sig) ctypes or struct from an h file

geremy condra debatem1 at gmail.com
Sun Oct 18 15:44:12 EDT 2009


On Sun, Oct 18, 2009 at 2:44 PM, Yuvgoog Greenle <ubershmekel at gmail.com> wrote:
> Is there a way that Python and C can have a shared definition for a
> binary data structure?
>
> It could be nice if:
> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
> to auto-generate constructors
> or
> 2. a ctypes definition could be exported to a .h file.
>
> So my question is - is there a way to do this in the std-lib or even pypi?
>
>
> --yuv

I wrote a bit of code a while ago that does something similar.
You can find it here: http://code.activestate.com/recipes/576734/.

Geremy Condra



More information about the Python-list mailing list