swapping numeric items in a list

Jiang Nutao jiangnutao at gmail.com
Wed Aug 23 15:22:12 EDT 2006


Thanks. But the thing I need to swap is [0x12, 0x34, 0x56, 0x78], not 
[0x1234, 0x5678].

----- Original Message ----- 
From: "Gabriel Genellina" <gagsl-py at yahoo.com.ar>
To: "Jiang Nutao" <jiangnutao at gmail.com>
Cc: "Gabriel Genellina" <gagsl-py at yahoo.com.ar>; <python-list at python.org>
Sent: Wednesday, August 23, 2006 12:19 PM
Subject: Re: swapping numeric items in a list


> At Wednesday 23/8/2006 15:32, Jiang Nutao wrote:
>
>>This is what I got in the debugger:
>>
>>(Pdb) aa=array('b', [126, 55, 71, 112])
>>(Pdb) aa
>>array('b', [126, 55, 71, 112])
>>(Pdb) aa.byteswap()
>>(Pdb) aa
>>array('b', [126, 55, 71, 112])
>
> Oh, sorry, to swap by two bytes "H" was the right typecode. But your input 
> array should be:
>>>>     aa = array('H', [0x1234, 0x5678])
> which should give:
>         array('H', [0x3412, 0x7856])
>
>
>
> Gabriel Genellina
> Softlab SRL
>
>
>
>
> __________________________________________________
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya! http://www.yahoo.com.ar/respuestas
>
> 




More information about the Python-list mailing list