import os data = map(lambda c: ord(c), file(args).read(os.path.getsize(args)))
For one file, os.path.getsize(args) returns 10456 while len(data) returns 281.
After looking at different files, I realized that it always stops reading at the 0x1A character.
The documentation says that in Windows, Python uses _wfopen which (for compatibility reasons) interprets 0x1A (CTRL-Z in DOS) as the end-of-file.
Does anyone know how to read an entire binary file which may contain 'x1A'?