Whatever happened to String Interpolation?

Tim Hammerquist tim at vegeta.ath.cx
Sun Dec 2 00:27:18 EST 2001


Fernando Pérez <fperez528 at yahoo.com> graced us by uttering:
[ snip ]
>         "x is $x, f(x) is $f(x)"
> 
> This to me is readable, unambiguous and very useful.

Ambiguity:

    Is that "the result of function f on variable x" or "the value of
    variable f, with the literal '(x)' after it"?

This slippery slope is one of many reasons many Pythonistas don't
want creeping featurism to infect their language.

(Perl has ways of disambiguating(?) the above expression, but it
leads to ugly code Pythonistas love to make fun of. eg:

    "x is $x, f(x) is @{[&f(x)]}"

That's the perl equivalent. )

Tim Hammerquist
-- 
Note that by displacing from "I got confused" to "It got confused", the
programmer is not avoiding responsibility, but rather getting some analytical
distance in order to be able to consider the bug dispassionately.
    -- Jargon File 4.3.1



More information about the Python-list mailing list