You are not logged in.
Why is is that in Python 3.3 (Arch x64), the file handler processes bytes in a weird order? Is this a bug or there's something else I do not know?
$ python
Python 3.3.0 (default, Sep 29 2012, 15:50:43)
[GCC 4.7.1 20120721 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> fo = open("filetest", "w")
>>> fo.write("\x00")
1
>>> fo.write("\x01")
1
>>> fo.write("\x02")
1
>>> fo.write("\x03")
1
>>> fo.close()
>>> fo = open ("filetest", "rb")
>>> bin = fo.read(4)
>>> print(bin)
b'\x00\x01\x02\x03'
But...
$ hexdump filetest
0000000 0100 0302
0000004
Last edited by moogtrain (2012-10-31 06:50:16)
Offline
I believe hexdump is reading in and displaying the file as a sequence of 2-byte integers; least significant byte first. Try doing:
hexdump -C filetest
Offline
Oh, you were right. Thanks.
Offline