<br><br><div class="gmail_quote">On Sat, Feb 21, 2009 at 12:21 PM, John Nagle <span dir="ltr"><<a href="mailto:nagle@animats.com">nagle@animats.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Steve Holden wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John Nagle wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Steve Holden wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John Nagle wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Benjamin Kaplan wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sun, Feb 15, 2009 at 11:57 AM, John Nagle <<a href="mailto:nagle@animats.com" target="_blank">nagle@animats.com</a>> wrote:<br>
<br>
</blockquote></blockquote></blockquote>
...Re "bytes" not behaving as documented in 2.6:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

   That's indeed how Python 2.6 works.  But that's not how<br>
PEP 3137 says it's supposed to work.<br>
<br>
Guido:<br>
<br>
 "I propose the following type names at the Python level:<br>
<br>
        * bytes is an immutable array of bytes (PyString)<br>
        * bytearray is a mutable array of bytes (PyBytes)"<br>
</blockquote></blockquote>
...<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

(Not true in Python 2.6<br>
Is this a bug, a feature, a documentation error, or bad design?<br>
<br>
</blockquote>
It's a feature. In fact all that was done to accommodate easier<br>
migration to 3.x is easily shown in one statement:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
str is bytes<br>
</blockquote></blockquote></blockquote>
True<br>
<br>
So that's why bytes works the way it does in 2.6 ... hence my contested<br>
description of it as an "ugly hack". I am happy to withdraw "ugly", but<br>
I think "hack" could still be held to apply.<br>
</blockquote>
   Agreed.  But is this a 2.6 thing, making 2.6 incompatible with 3.0, or<br>
what?  How will 3.x do it?  The PEP 3137 way, or the Python 2.6 way?<br>
<br>
   The way it works in 2.6 makes it necessary to do "ord" conversions<br>
where they shouldn't be required.<br>
<br>
</blockquote>
Yes, the hack was to achieve a modicum of compatibility with 3.0 without<br>
having to turn the world upside down.<br>
<br>
I haven't used 3.0 enough the say whether bytearray has been correctly<br>
implemented. But I believe the intention is that 3.0 should fully<br>
implement PEP 3137.<br>
</blockquote>
<br>
   If "bytes", a new keyword, works differently in 2.6 and 3.0, that was really<br>
dumb.  There's no old code using "bytes".  So converting code to 2.6 means<br>
it has to be converted AGAIN for 3.0.  That's a good reason to ignore 2.6 as<br>
defective.<br>
</blockquote><div><br>"""<br>
<p>The primary use of <tt class="xref docutils literal"><span class="pre">bytes</span></tt> in 2.6 will be to write tests of
object type such as <tt class="docutils literal"><span class="pre">isinstance(x,</span> <span class="pre">bytes)</span></tt>.  This will help the 2to3
converter, which can't tell whether 2.x code intends strings to
contain either characters or 8-bit bytes; you can now
use either <tt class="xref docutils literal"><span class="pre">bytes</span></tt> or <a title="str" class="reference external" href="http://docs.python.org/library/functions.html#str"><tt class="xref docutils literal"><span class="pre">str</span></tt></a> to represent your intention
exactly, and the resulting code will also be correct in Python 3.0.</p><p>"""<br></p><br>The reason for putting bytes (a new type, not a keyword) into 2.6 was purely for use in the 2to3 tool. It is designed to break less code on the conversion from 2.x to 3.x, not to add extra features to 2.6+.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
                                        John Nagle<br><font color="#888888">
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>