Whatever happened to String Interpolation?

Skip Montanaro skip at pobox.com
Sat Dec 1 15:47:03 EST 2001


    fp> Andreas Kostyrka wrote:
    >> What about "%%%(x)s%%" % locals()

    fp> I'm looking for _clarity_ in the code. I've already written enough
    fp> perl code in my life for things like that.

Well, what happens to the next person who comes along and wants to embed
literal $ in his/her interpolated strings?  I believe using your scheme (or
the PEP 215 scheme) they wind up with something like

    "$$$x$$" % locals()

or

    "$$${x}$$" % locals()

(or something else similar) which isn't all that readable either.  You just
happen to want to embed literal %-signs in your strings.  Please correct me
if I'm wrong, but changing the character that introduces a value to be
interpolated just moves the problem around a bit.  I don't think it solves
anything.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list