Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-17 Thread wallenpb
On Mar 16, 5:42 pm, John Machin wrote: > On Mar 17, 9:29 am, "R. David Murray" wrote: > > > > > walle...@gmail.com wrote: > > > On Mar 16, 4:10 pm, Benjamin Peterson wrote: > > > >   gmail.com> writes: > > > > > > self.out.write(b'BM') worked beautifully.  Now I also have a similar > > > > > iss

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread John Machin
On Mar 17, 9:29 am, "R. David Murray" wrote: > walle...@gmail.com wrote: > > On Mar 16, 4:10 pm, Benjamin Peterson wrote: > > >   gmail.com> writes: > > > > > self.out.write(b'BM') worked beautifully.  Now I also have a similar > > > > issue, for instance: > > > > self.out.write("%c" % y) is also

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread Scott David Daniels
R. David Murray wrote: ... Here is some example code that works: out=open('temp', "wb") out.write(b"BM") def write_int(out, n): bytesout=bytes(([n&255), (n>>8)&255, (n>>16)&255, (n>>24)&255]) out.write(bytesout) write_int(out, 125) or even: import struct

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread R. David Murray
walle...@gmail.com wrote: > On Mar 16, 4:10 pm, Benjamin Peterson wrote: > >   gmail.com> writes: > > > > > > > > > self.out.write(b'BM') worked beautifully.  Now I also have a similar > > > issue, for instance: > > > self.out.write("%c" % y) is also giving me the same error as the other > > > sta

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread Terry Reedy
walle...@gmail.com wrote: Thanks for the assist. One more question, please. self.out.write(b'BM') worked beautifully. Now I also have a similar issue, for instance: self.out.write("%c" % y) is also giving me the same error as the other statement did. I tried self.out.write(bytes("%c" %y),

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread wallenpb
On Mar 16, 4:10 pm, Benjamin Peterson wrote: >   gmail.com> writes: > > > > > self.out.write(b'BM') worked beautifully.  Now I also have a similar > > issue, for instance: > > self.out.write("%c" % y) is also giving me the same error as the other > > statement did. > > I tried self.out.write(bytes

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread Benjamin Peterson
gmail.com> writes: > > self.out.write(b'BM') worked beautifully. Now I also have a similar > issue, for instance: > self.out.write("%c" % y) is also giving me the same error as the other > statement did. > I tried self.out.write(bytes("%c" %y),encoding=utf-8) in an attempt to > convert to bytes

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread wallenpb
On Mar 16, 11:05 am, "R. David Murray" wrote: > walle...@gmail.com wrote: > > I am working with a bit of code that works ok in Python 2.x (tested > > fine in 2.5.4 and 2.6.1) but fails in 3.0.1. > > The code opens a file for binary output to witht the objective to > > produce a .bmp graphics file.

error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread R. David Murray
walle...@gmail.com wrote: > I am working with a bit of code that works ok in Python 2.x (tested > fine in 2.5.4 and 2.6.1) but fails in 3.0.1. > The code opens a file for binary output to witht the objective to > produce a .bmp graphics file. The code below illustrates the first of > several like

error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread wallenpb
I am working with a bit of code that works ok in Python 2.x (tested fine in 2.5.4 and 2.6.1) but fails in 3.0.1. The code opens a file for binary output to witht the objective to produce a .bmp graphics file. The code below illustrates the first of several like errors when a str object is attempte