<br><br><div class="gmail_quote">On Sun, Oct 31, 2010 at 1:32 AM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Sat, Oct 30, 2010 at 9:21 PM, André <<a href="mailto:andre.roberge@gmail.com">andre.roberge@gmail.com</a>> wrote:<br>
> On Oct 31, 1:11 am, Chris Rebert <<a href="mailto:c...@rebertia.com">c...@rebertia.com</a>> wrote:<br>
<div class="im">>> On Sat, Oct 30, 2010 at 8:32 PM, André <<a href="mailto:andre.robe...@gmail.com">andre.robe...@gmail.com</a>> wrote:<br>
>> > I'm trying to create pbm (portable bitmap) files using Python 3 and<br>
>> > have run into a problem.   The example I am using is the Python 2<br>
>> > Mandelbrot program found at<br>
</div>>> ><a href="http://shootout.alioth.debian.org/u32/program.php?test=mandelbrot&lan." target="_blank">http://shootout.alioth.debian.org/u32/program.php?test=mandelbrot&lan.</a>..<br>
<div class="im">>><br>
>> > When I run it using Python 2 with size=100, I get a file of size 1311<br>
>> > bytes.  This file contains the correct image.<br>
>><br>
>> > When I run it using Python 3 with the same parameter (and replacing<br>
>> > xrange by range - the only change suggested by 2to3), I get a file of<br>
>> > size 1812 bytes; this file does not contain the right image.<br>
>><br>
>> > Any help would be much appreciated.<br>
>><br>
</div><div class="im">>> Have you tried changing all instances of chr(<whatever>) to<br>
>> bytes([<whatever>]) ?<br>
</div>> Yes, I had.  And I got the following traceback:<br>
><br>
> Traceback (most recent call last):<br>
>  File "mandel_orig.py", line 39, in <module><br>
>    main()<br>
>  File "mandel_orig.py", line 30, in main<br>
>    cout(bytes([byte_acc]))<br>
> TypeError: must be str, not bytes<br>
<br>
Ah, right. This is the problem of not having Python 3 to test with.<br>
Try also changing:<br>
cout = sys.stdout.buffer.write<br></blockquote><div><br>Yes, that worked.  Thanks!<br><br>Now I know what to look for, time to read the documentation for sys.stdout.buffer ...   Thanks again.<br><br>André<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5"><br>
Cheers,<br>
Chris<br>
--<br>
<a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
</div></div></blockquote></div><br>