[Python-ideas] One way to do format and print

Stephen J. Turnbull stephen at xemacs.org
Wed Sep 9 05:05:44 CEST 2015


random832 at fastmail.us writes:

 > My take is: Having two format string grammars is worse than having
 > one, even if the %-grammar is worse than the {}-grammar.

The same has been said for having two (or more) loop grammars.

    Where have you gone, Repeat Until
    A nation turns its lonely eyes to you
    What's that you say, Mrs Robinson
    Pascal itself has turned to Modula 2 (or 3) (how 'bout 4?!)

The point is that not all experiments can be contained in a single
personal branch posted to GitHub.  (Kudos to Trent who seems to be
pulling off that trick as we controverse.  Even if it's possible it's
not necessarily easy!)  We all agree in isolation with the value you
express (more or less TOOWTDI), but it's the balance of many
desiderata that makes Python a great language.  But that balance
clearly is against you: At the time {}-formatting was introduced,
there had already been several less-than-wildly-successful experiments
(including string.Template), yet the PEP was nevertheless accepted.

In string formatting, the consensus is evidently that it's difficult
enough to measure improvement objectively that sufficiently plausible
experiments will still be admitted into the stdlib (or not, in the
case of the much-delayed PEP 461 -- way to go, Ethan! -- the decision
*not* to have backward compatible formatting for bytestrings was
itself an experiment in this sense).  And it's a difficult enough
design space that the principle of minimal sufficient change (implicit
in what you're saying) was not strictly applied to {}-formatting (or
string.Template, for that matter).

I'm not just being ornery, string formatting is near and dear to my
heart.  I'm genuinely curious why you choose a much more conservative
balance in this area than Python has.  But to my eyes your posts so
far amount to an attempted wake-up call: "TOOWTDI is more important in
string formatting than you all seem to think!" and no more.

Sincere regards,


More information about the Python-ideas mailing list