[Python-Dev] Re: PEP 292, Simpler String Substitutions

François Pinard pinard@iro.umontreal.ca
19 Jun 2002 22:43:53 -0400


[Guido van Rossum]

> The $ means "substitution" in so many languages besides Perl that I
> wonder where you've been.

Of course, I've been elsewhere.  But Python currently uses `%' for driving
interpolation, and on this topic, I've been with Python, if you wonder :-).

> I quite like the positional % substitution.  I think %(...)s was a
> mistake -- what we really wanted was ${...}.

The distinction between %()s and %()r, recently introduced, has been useful.
But with str() and repr(), only one of those is really necessary.  But it
gave the impression that Python trend is pushing for % to get stronger.
The proposal of using $ as yet another formatting avenue makes it weaker.

> Less clutter.  Compare

>     "My name is $name, I live in $country"

> to

>     "My name is ${name}, I live in ${country}"

> The {} add nothing but noise.  We're copying this from the shell.

Noise decreases legibility.  So, maybe the PEP should not say that ${name}
is to be preferred over $name?  Or else, it should explain why.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard