[Python-3000] Please don't kill the % operator...

Jim Jewett jimjjewett at gmail.com
Thu Aug 16 23:50:50 CEST 2007


On 8/16/07, Brett Cannon <brett at python.org> wrote:

> But how is::

>   "{0} is happy to see {1}".format('Brett', 'Christian')

> that less easier to read than::

>   "%s is happy to see %s" % ('Brett', 'Christian')

Excluding minor aesthetics, they are equivalent.

The new format only has advantages when the formatting string is
complicated.  So the real question is:

Should we keep the old way for backwards compatibility?

Or should we force people to upgrade their code (and their translation
data files), even if their code doesn't benefit, and wouldn't need to
change otherwise?

Remember that most of the time, the old way worked fine, and it will
be the new way that seems redundant.  Remember also that 2to3 won't
get this change entirely right.  Remember that people can already
subclass string.Template if they really do need fancy logic.  Note
that this removal alone would go a huge way toward preventing code
that works in both 3.0 and 2.5 (or 2.2).


> But just saying you like %s over {0} is
> like saying you don't like the decorator syntax: that's nice and all,
> but that is not a compelling reason to change the decision being made.

It is more like saying you prefer the old style of rebinding the name.
 Adding the new format is one thing; removing the old is another.

-jJ


More information about the Python-3000 mailing list