[Python-Dev] PEP 292, Simpler String Substitutions

Guido van Rossum guido@python.org
Wed, 19 Jun 2002 22:15:58 -0400


> If there were an easy way to do interpolation I might well want to
> teach it before any of str() or string concatenation.

I'm afraid your students would end up appending a character c to a
string s by writing

    s = "$s$c".sub()

Not exactly good style.

> And I would probably treat it in preference to the magic and special
> "," operator of the print statement.

I object to this insinuation.

> I prefer to teach something that is generally useful like $ rather
> than something which they may have to unlearn like "," -- unlearn to
> the extent that they will naturally expect that commas in other
> contexts will do whitespace-generating concatenation and they hardly
> ever will.

(a) You're making this argument up.  I don't believe for a second that
    you've observed this mistake in an actual student.

(b) I expect that students never even *think* about the space between
    printed items -- it's entirely natural.

(c) Commas are designed to "disappear" in our interpretation of
    things, and they do.  The comma has so many uses where whitespace
    generation is just not one of the things you could possibly think
    about that I find it hard to take this argument serious.

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