Byte oriented data types in python

Grant Edwards grante at visi.com
Sun Jan 25 12:46:10 EST 2009


On 2009-01-25, Ravi <ra.ravi.rav at gmail.com> wrote:
>
>> Take a look at the struct and ctypes modules.
>
> struct is really not the choice. it returns an expanded string of the
> data and this means larger latency over bluetooth.

I don't know what you mean by "returns an expanded string of
the data".

I do know that struct does exactly what you requested.

It converts between Python objects and what is bascially a C
"struct" where you specify the endianness of each field and
what sort of packing/padding you want.

I use the struct module frequenty to impliment binary,
communications protocols in Python.  I've used Python/struct
with transport layers ranging from Ethernet (raw, TCP, and UDP)
to async serial, to CAN.

-- 



More information about the Python-list mailing list