<div dir="ltr"><div style class="markdown-here-wrapper" id="markdown-here-wrapper-129300"><p style="margin:1.2em 0px!important">2014-03-28 18:17 GMT+01:00 Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>>:</p>


<p style="margin:1.2em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><div dir="ltr">

<div class=""><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 28, 2014 at 10:06 AM, Benjamin Peterson <span dir="ltr"><<a href="mailto:benjamin@python.org" target="_blank">benjamin@python.org</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
</div>I agree. We would add a method that iterates over single bytes as bytes<br>
objects instead of integers.<br></blockquote></div><br></div></div><div class="gmail_extra">Now that's making sense.<span class=""><font color="#888888"><br clear="all"></font></span></div><span class=""></span></div>

</blockquote><p></p></div><p style="margin:1.2em 0px!important"></p>
<p style="margin:1.2em 0px!important">even if some people don’t like it, the iterating over bytes objects makes perfect sense.</p>
<p style="margin:1.2em 0px!important">in every statically typed language, a <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">byte</code> is most commonly repesented as an integer in the range [0,255].</p>


<p style="margin:1.2em 0px!important">the annoyance has two sources:</p>
<ol style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">python 2 byte strings (aka “native strings”) behaved like that (and unicode strings behave like that because python has no <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">char</code> type)</p>


</li>
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">byte strings are represented like strings, including ascii-compatible parts as if they were ASCII text.</p>
</li>
</ol>
<p style="margin:1.2em 0px!important">therefore, paople think single bytes would be something akin to chars instead of simply integers from 0 to 255.</p>
<p style="margin:1.2em 0px!important"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">b'a'[0] == 97</code> looks strange, but let’s not forget that it’s actually <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">b'\x61'[0] == 0x61</code></p>


</div></div>