On 03/26/2014 08:14 AM, Thomas Wouters wrote:
On Tue, Mar 25, 2014 at 11:37 PM, Ethan Furman wrote:

    In particular, ``%s`` will not accept numbers (use a numeric format code for
    that), nor ``str`` (encode it to ``bytes``).


I don't understand this restriction, and there isn't a rationale for it in the PEP 
(other than "you can already use
numeric formats", which doesn't explain why it's undesirable to have it 
anyway.) It is extremely common in existing 2.x
code to use %s for anything

And that's the problem -- in 2.x %s works always, but 3.x for bytes and 
bytearray %s will fail in numerous situations.

It seems to me the main reason for using %s instead of %d is that 'some_var' may have a number, or it may have the textual representation of that number; in 3.x the first would succeed, the second would fail. That's the kind of intermittent failure we do not want.

The PEP is not designed to make it so 2.x code can be ported as-is, but rather that 2.x code can be cleaned up (if necessary) and then run the same in both 2.x and 3.x (at least as far as byte and bytearray %-formatting is concerned).

 Did this come up in the earlier discussions?

https://mail.python.org/pipermail/python-dev/2014-January/131576.html

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to