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

skip at pobox.com skip at pobox.com
Thu Aug 16 17:05:36 CEST 2007


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.

    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???

Skip


More information about the Python-3000 mailing list