osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing bytes to stdout reverses the bytes


When I write bytes to stdout, why are they reversed?

[steve at ando ~]$ python2.7 -c "print('\xfd\x84\x04\x08')" | hexdump
0000000 84fd 0804 000a
0000005

[steve at ando ~]$ python3.5 -c "import sys; sys.stdout.buffer.write(b'\xfd
\x84\x04\x08\n')" | hexdump
0000000 84fd 0804 000a
0000005




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson