[Python-Dev] PEP 461 - Adding % and {} formatting to bytes

Glenn Linderman v+python at g.nevcal.com
Fri Jan 17 20:04:13 CET 2014


On 1/17/2014 6:50 AM, Eric V. Smith wrote:
> Following up, I think this leaves us with 3 choices:
>
> 1. Do not implement bytes.format(). We tell any 2.x code that's written
> to use str.format() to switch to %-formatting for their common code base.
>
> 2. Add the simplistic version of bytes.format() that I describe above,
> restricted to accepting bytes, int, and float (and no subclasses). Some
> 2.x code will work, some will need to change to %-formatting.
>
> 3. Add bytes.format() and the __format_ascii__ protocol. We might want
> to also add a format_ascii() builtin, to match __format__ and format().
> This would require the least change to 2.x code that uses str.format()
> and wants to move to bytes.format(), but would require some work on the
> 3.x side.
>
> I'd advocate 1 or 2.

Nice summary.

I'd advocate 1 or 3.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140117/293f86ee/attachment.html>


More information about the Python-Dev mailing list