low level data types

Simon Brunning simon at brunningonline.net
Wed Feb 15 09:52:39 EST 2006


On 15 Feb 2006 04:07:37 -0800, dementrio <dementrio at gmail.com> wrote:
> How can I handle low-level data types in Python?
> What I want to do is writing an interface to a C daemon which waits for
> stuff like unsigned ints on a socket. For example, I need to craft and
> decode data structures that look like this:
>
> 32-bit unsigned int MSG_LENGTH
> 32-bit unsigned int MSG_CODE
> 64-bit signed int DATA
> 32-bit length + utf-8 characters STRING_DATA
> etc.
>
> What's the right way to do this in Python?

Look at the struct module.

--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list