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

Guido van Rossum guido at python.org
Thu Aug 16 18:38:32 CEST 2007


On 8/16/07, skip at pobox.com <skip at pobox.com> wrote:
>
> Thanks for the detailed response.
>
>     Guido> Now on to the transition. On the one hand I always planned this
>     Guido> to *replace* the old %-formatting syntax, which has a number of
>     Guido> real problems: "%s" % x raises an exception if x happens to be a
>     Guido> tuple, and you have to write "%s" % (x,) to format an object if
>     Guido> you aren't sure about its type; also, it's very common to forget
>     Guido> the trailing 's' in "%(name)s" % {'name': ...}.
>
> I was conflating the format string and the % operator in some of my (casual)
> thinking.  I'm much less married to retaining the % operator itself (that is
> the source of most of the current warts I believe), but as you pointed out
> some of the format string proposals are pretty scary.

Which is why they won't be accepted. ;-)

To clarify the % operator is the cause of the first wart; the second
wart is caused by the syntax for individual formats. Keeping one but
changing the other seems to keep some of the flaws of one or the other
while still paying the full price of change, so this isn't an option.

>     Guido> I don't know what percentage of %-formatting uses a string
>     Guido> literal on the left; if it's a really high number (high 90s), I'd
>     Guido> like to kill %-formatting and go with mechanical translation;
>     Guido> otherwise, I think we'll have to phase out %-formatting in 3.x or
>     Guido> 4.0.
>
> Yow!  You're already thinking about Python 4???

I use it in the same way we used to refer to Python 3000 in the past. :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list