Reading c struct via python

Lakshmipathi.G lakshmipathi.g at
Wed Nov 13 18:59:03 CET 2013

> Looks like your "e"... Is that the key field?

Yes, you are right 'e' is the key. And rest of them are data.

>AND the order of the items is "o" before "i"
>-- that doesn't seem to match your C struct definition.

Sorry, I was testing the bdb and while doing that I noticed,
c-struct order is not same as inserted bdb record . But forgot to
fix the struct order before posting it here.

(And also I didn't expect someone will dig this deeper on the binary
string output :p . Thanks for your effort! )

>"s" format in which you precode the length of the string in the
>format ("10s" is a 10 character string), and "p" format in which the first
>byte of the string is the length (0..255) of the rest of the string. The
>struct module doesn't handle C-type null terminated strings directly.

I think we can use 'p' format. (Thus storing the string-length before
string content). That should help us unpack easily.

Thanks  Dennis Lee Bieber, for the detailed info and step by step parsing
of the output. It really helped.

>         Wulfraed                 Dennis Lee Bieber         AF6VN
>     wlfraed at    HTTP://
> --

FOSS Programmer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list