On Sat, Oct 6, 2012 at 11:26 PM, Grant Edwards <[email protected]> wrote: > On 2012-10-06, Dennis Lee Bieber <[email protected]> wrote: >> On Fri, 5 Oct 2012 20:27:36 -0700 (PDT), palmeira <[email protected]> >> declaimed the following in gmane.comp.python.general: >> >>> >>> #WRITE >>> fb=open('testOUT.bin') >> >> Unless you specify otherwise, open() defaults to read-only > > It also defaults to 'text' mode which does cr/lf translaction. That > will break both reads and writes on any binary file containing 0x0a > and 0x0d bytes.
And, in Python 3, it'll be returning Unicode characters too, unless the decode fails. You definitely want binary mode. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
