<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#330033">
<div class="moz-cite-prefix">On 3/27/2014 11:59 AM, Guido van Rossum
wrote:<br>
</div>
<blockquote
cite="mid:CAP7+vJ+cGVChR8UNbCPfgTWEGO+Up_b2i-tg7GZpk6FuvoeNig@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Mar 27, 2014 at 11:52 AM,
Daniel Holth <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dholth@gmail.com" target="_blank">dholth@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">I feel
not including %s is nuts. Should I write .replace('%b',
'%s')?<br>
</blockquote>
<div><br>
I assume you meant .replace('%s', '%b') (unless you're
converting Python 3 code to Python 2, which would mean you
really are nuts :-).<br>
<br>
But that's not going to help for the majority of code
using %s -- as I am trying to argue, %s doesn't mean
"expect the argument to be a str" and neither is that how
it's commonly used (although it's *possible* that that is
how *you* use it exclusively -- that doesn't make you
nuts, just more strict than most people).<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
That _is_ how it is commonly used in Py2 when dealing with binary
data in mixed ASCII/binary protocols, is what I've been hearing in
this discussion, and what small use I've made of Py2 when some
unported module forced me to use it (I started Python about the time
Py3 was released)... the expected argument is a (Py2) str containing
binary data (would be bytes in Py3).<br>
<br>
While there are many other reasons to use %s in other coding
situations, this is the only way to do bytes interpolations using %.
And there is no %b in Py2, so for Py2/3 compatibility, %s needs to
do bytes interpolations in Py3. And if it does, there is no need for
%b in Py3 %, because they would be identical and redundant.<br>
<br>
<blockquote
cite="mid:CAP7+vJ+cGVChR8UNbCPfgTWEGO+Up_b2i-tg7GZpk6FuvoeNig@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
All I desperately need are APIs that provide enough
unicode / str type<br>
safety that I get an exception when mixing them
accidentally... in my<br>
own code, dynamic typing is usually a bug. As has been
endlessly<br>
discussed, %s for bytes is a bit like exposing
sprintf()...<br>
</blockquote>
<div><br>
</div>
<div>I don't understand that last claim (I can't figure out
whether in this context is exposing sprintf() is
considered good or bad). But apart from that, can you give
some specific examples?<br>
<br>
</div>
<div>PS. I am not trying to be difficult. I honestly don't
understand the use case yet, and the PEP doesn't do much
to support it.<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>