[Python-Dev] PEP 461 - Adding % and {} formatting to bytes (original) (raw)

Glenn Linderman v+python at g.nevcal.com
Wed Jan 15 22:04:41 CET 2014


On 1/15/2014 7:52 AM, Eric V. Smith wrote:

So basically I think we'll have to hard-code the types that .format() will support, and never call format, or only call format if we know that it's a exact type where we know that format will return (strict ASCII).

Either that, or we're back to encoding the result of format and accepting that sometimes it might throw errors, depending on the values being passed into format().

Looks like you need to invent formatb to produce only ASCII. Objects that have formatb can be formatted by bytes.format. To avoid coding, it could be possible that formatb might be a callable, in which case it is called to get the result, or not a callable, in which case one calls format and converts the result to ASCII, formatb just indicating a guarantee that only ASCII will result.

Or it could be that formatb replaces format and str.format, if it finds no format looks for formatb, calls that, and converts the result to Unicode. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140115/deba74a3/attachment.html>



More information about the Python-Dev mailing list