On Mon, Aug 20, 2018 at 10:31 AM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> When I write bytes to stdout, why are they reversed?
>
> [steve@ando ~]$ python2.7 -c "print('\xfd\x84\x04\x08')" | hexdump
> 0000000 84fd 0804 000a
> 0000005
>
> [steve@ando ~]$ python3.5 -c "import sys; sys.stdout.buffer.write(b'\xfd
> \x84\x04\x08\n')" | hexdump
> 0000000 84fd 0804 000a
> 0000005

They're not. They're being printed out as individual bytes, but then
the hexdump command is looking at little-endian sixteen-bit units. Try
the 'hd' command instead, or use 'hexdump -C'.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to