On Mon, Jul 28, 2008 at 5:45 AM, Scott David Daniels
<[EMAIL PROTECTED]> wrote:
> Alan Franzoni wrote:
>>
>> Michael Torrie was kind enough to say:
>>
>>> Of course any time you send coherent numbers over the network, I highly
>>> recommend you use what's called network byte order....  I'm sure python
>>> has some convention in the struct module for dealing with this.
>>
>> Not in the struct module; such functions are available in the socket
>> module, and should be employed indeed.
>
> Please don't pass this misinformation along.
>
> In the struct module document, see the section on the initial character:
>    Character Byte order Size and alignment
>      @          native            native
>      =          native           standard
>      <       little-endian       standard
>      >        big-endian         standard
>      !    network (= big-endian) standard
>  and notes @ is the default.
>>>> print struct.pack('<lh', 3,4)
>>>> print struct.pack('>lh', 3,4)
>>>> print struct.pack('lh', 3,4)
>>>> print struct.pack('!lh', 3,4)


thanks for clarifying, and just to make sure, i am using '!' format
from the struct package... i had this even in my previous email....
what am doing below is fine right?


this is short
>>> struct.pack('!h',3)
'\x00\x03'

this is integer
>>> struct.pack('!i',3)
'\x00\x00\x00\x03'

this is long
>>> struct.pack('!l',3)
'\x00\x00\x00\x03'
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to