[Python-Dev] PEP 215 redux: toward a simplified consensus?

Guido van Rossum guido@python.org
Mon, 25 Feb 2002 16:06:15 -0500

> String interopolation should be a *compile time* action, not an
> operator. One of the goals, in my mind, is to allow people to string
> interpolate without knowing what the locals() function does. After all,
> that function is otherwise useless for most Python programmers (and
> should probably be moved to an introspection module). 
> Your strategy requires the naive user to learn a) the $ syntax, b) the
> magic operator syntax and c) the meaning of the locals() function. Plus
> you've thrown away the idea that interpolation works as it does in the
> shell or in Perl/Awk/Ruby etc.
> At that point, in my mind, we're back where we started and should just
> use %. Well have reinvented it with a few small tweaks.
> Plus, operator-based evaluation has some security implications that
> compile time evaluation does not. In particular, if the left-hand thing
> can be any string then you have the potential of accidentally allowing
> the user to supply a string that allows him/her to introspect your local
> variables. That can't happen if the interpolation is done at compile
> time.

All right, but there *also* needs to be a way to invoke interpolation
explicitly -- just like eval().  This has applicability e.g. in i18n.

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