[Python-Dev] PEP 292, Simpler String Substitutions

Ka-Ping Yee ping@zesty.ca
Thu, 20 Jun 2002 15:48:52 -0700 (PDT)

On Thu, 20 Jun 2002, Oren Tirosh wrote:
> See http://tothink.com/python/embedpp

Hi Oren,

Your proposal brings up some valid concerns with PEP 215:

    1. run-time vs. compile-time parsing
    2. how to decide what's an expression
    3. balanced quoting instead of $

PEP 215 actually agrees with you on point #1.  That is, the intent
(though poorly explained) was that the interpolated strings would be
turned into bytecode by the compiler.  That is why the PEP insists on
having the interpolated expressions in the literal itself -- they
can be taken apart at compile time.

However, i don't necessarily agree with PEP 215.  (I mentioned this
once before, but it might not hurt to reiterate that i didn't write
the PEP because i desperately wanted string interpolation.  I wrote
it because i wanted to try to get one local optimum written down in
a PEP, so there would be something for discussion.)

Using compile-time parsing, as in PEP 215, has the advantage that it
avoids any possible security problems; but it also eliminates the
possibility of using this for internationalization.  I see this as
the key tension in the string interpolation issue (aside from all
the syntax stuff -- which is naturally controversial).

-- ?!ng

"Computers are useless.  They can only give you answers."
    -- Pablo Picasso