<div dir="ltr"><div><div><div><div><div><div><div>To avoid implicit conversion between str and bytes, I propose adding only limited %-format,<br></div>not .format() or .format_map().<br><br></div>"limited %-format" means:<br>


</div><br>%c accepts integer or bytes having one length.<br></div>%r is not supported<br></div>%s accepts only bytes.<br></div>%a is only format accepts arbitrary object.<br></div><br>And other formats is same to str.<br>


<div><div><div><div> <br></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 11, 2014 at 8:24 AM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 10 Jan 2014 18:14:45 -0500<br>
<div class="im">"Eric V. Smith" <<a href="mailto:eric@trueblade.com">eric@trueblade.com</a>> wrote:<br>
><br>
</div><div class="im">> >> Because embedding the ASCII equivalent of ints and floats in byte streams<br>
> >> is a common operation?<br>
> ><br>
> > Again, if you're representing "ASCII", you're representing text and<br>
> > should use a str object.<br>
><br>
> Yes, but is there existing 2.x code that uses %s for int and float<br>
> (perhaps unwittingly), and do we want to "help" that code out?<br>
> Or do we<br>
> want to make porters first change to using %d or %f instead of %s?<br>
<br>
</div>I'm afraid you're misunderstanding me. The PEP doesn't allow for %d and<br>
%f on bytes objects.<br>
<div class="im"><br>
> I think what you're getting at is that in addition to not calling<br>
> __format__, we don't want to call __str__, either, for the same reason.<br>
<br>
</div>Not only. We don't want to do anything that actually asks for a<br>
*textual* representation of something. %d and %f ask for a textual<br>
representation of a number, so they're right out.<br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888"><br>
Antoine.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com" target="_blank">https://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>INADA Naoki  <<a href="mailto:songofacandy@gmail.com">songofacandy@gmail.com</a>>
</div>