On Mon, 24 Feb 2014 08:54:08 +1000 Nick Coghlan <ncogh...@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. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com