python alternatives to C structs??

Aaron Brady castironpi at gmail.com
Sat Apr 18 21:33:03 EDT 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