On 1/13/2014 10:40 AM, Brett Cannon wrote:
This even gives people in-place ASCII encoding for strings by always
using '{:s}' with text which they can do when they port their code to
run under both Python 2 and 3. So you should be able to do
``b'Content-Type: {:s}'.format('image/jpeg')`` and have it give ASCII.
If you want more explicit encoding to latin-1 then you need to do it
explicitly and not rely on the mini-language to do tricks for you.
My preference is not have any, but if Guido is going say PBP here then
I want absolute consistency across the board in how bytes.format()
tweaks things.
As for %s for the % operator calling ascii(), I think that will be a
porting nightmare of finding out why your bytes suddenly stopped being
formatted properly and then having to crawl through all of your code
for that one use of %s which is getting bytes in. By raising a
TypeError you will very easily detect where your screw-up occurred
thanks to the traceback; do so otherwise feels too much like implicit
type conversion and ask any JavaScript developer how that can be a bad
thing.
So quote 3 is necessarily a violation of quote 1. But if quote 2 can
allow for one exception to its absolute consistency... that is probably
the best solution overall...
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com