On Thu, Mar 27, 2014 at 11:34 AM, Ethan Furman <ethan at stoneleaf.us> wrote: > On 03/27/2014 11:24 AM, Guido van Rossum wrote: > >> On Thu, Mar 27, 2014 at 10:55 AM, Ethan Furman wrote: >> >>> >>> The biggest reason to use %s is to support a common code base for 2/3 >>> endeavors. >>> >> >> But it's mostly useless for that purpose. In Python 2, in practice %s >> doesn't mean "string". [...] >> > > In Python 2 if one is using 'str' as a 'bytes' container, and doing > interpolation, %s is the only choice available for other 'bytes' (aka other > 'str's). Note that I'm happy to be proven wrong on this point. :) > That is true. And we can't change Python 2. I still have this idea in my head that *most* cases where %s is used in Python 2 will break in Python 3 under the PEP's rules, but perhaps they are not the majority of situations where the context is manipulating bytes. And I suppose that *very* few internet protocols are designed to accept either an integer or the literal string None, so that use case (which I brought up) isn't very realistic -- in fact it may be better to raise an exception rather than sending a protocol violation. So, I think you have changed my mind. I still like the idea of promoting %b in pure Python 3 code to emphasize that it really behaves very differently from %s; but I now have peace with %s as an alias. (It might also benefit cases where somehow there's a symmetry in some Python 3 code between bytes and str.) -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140327/ed50a725/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4