python alternatives to C structs??

Aaron Brady castironpi at gmail.com
Sun Apr 19 03:33:03 CEST 2009


On Apr 18, 2:25 pm, KoolD <sourya... at gmail.com> wrote:
> Hey all,
> I need to convert a C code to python please help me figure out how to
> do
> it.
> Suppose the C program's like:
>
> ------------------------------------
> typedef struct _str
> {
> int a;
> char *b;
> int c;}str;
>
> int main()
> {
> str mbr;
> fd=open("/dev/sda",O_RDONLY);
> read(fd,&mbr,sizeof(str));}
>
> ------------------------------------
>
> Is there a way to code it in python.
>
> Thanks
> Sourya

There is the 'ctypes' module, but you might also need 'mmap', for the
'read( &mbr )' operation.



More information about the Python-list mailing list