A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-February/132728.html below:

[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2Antoine Pitrou solipsis at pitrou.net
Mon Feb 24 00:04:33 CET 2014
On Mon, 24 Feb 2014 08:54:08 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> > > The idea being if we offer %a, folks won't be tempted to abuse
> __bytes__.
> >
> > Which folks are we talking about? This sounds gratuitous.
> 
> It's a harm containment tactic, based on the assumption people *will* want
> to include the output of ascii() in binary protocols containing ASCII
> segments

But why would they? ascii() doesn't do what they want, since it's
repr()-like, not str()-like. It seems your assumption is wrong.

> By contrast, if %a doesn't exist, then it becomes more attractive to use %s
> in the format string and define an ASCII assuming  __bytes__ implementation
> on a custom type.

Uh... Few Python programmers would actually think of writing a __bytes__
method just to enable bytes interpolation for their custom types.
However, adding "%a" as a supported interpolation format just makes
things confusing for *everyone*.

Regards

Antoine.
More information about the Python-Dev mailing list

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