On Wed, Apr 24, 2013 at 4:21 PM, Prasad, Ramit
<ramit.pra...@jpmorgan.com> wrote:
> Your struct.pack() line seems fine, but you might want to specify
> endian-ness as the default value may vary by architecture.
> (See http://en.wikipedia.org/wiki/Endian )
>
>>>> struct.pack('>HBB', 1234,1,0 )
> '\x04\xd2\x01\x00' # note location of 4 and d2
>>>> struct.pack('<HBB', 1234,1,0 )
> '\xd2\x04\x01\x00' # note location of 4 and d2 are swapped

struct.pack returns bytes in 3.x, not a string as shown above.
Remember to use b''.join instead of ''.join if the groups are being
joined into a larger buffer.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to