Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Reading c struct via python

67 views
Skip to first unread message
Message has been deleted

Lakshmipathi.G

unread,
Nov 13, 2013, 12:59:03 PM11/13/13
to Dennis Lee Bieber, pytho...@python.org
> 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 actual 
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
    wlf...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

--
https://mail.python.org/mailman/listinfo/python-list



--
----
Cheers,
Lakshmipathi.G
FOSS Programmer.
www.giis.co.in
0 new messages