[Python-3000] interpolated strings
Fredrik Lundh
fredrik at pythonware.com
Wed Dec 6 13:04:27 CET 2006
Antoine wrote:
> s = i"some string here with {variable} in it"
>
> The Interpolation object captures the format string, as well as a dict of
> the needed variables from the current locals and globals (here, the
> "variable").
I'm not sure I can think of a way to explain to a new Python programmer that
she needs to inline all her string literals...
(people who do interpolation tend to expect dynamic lexical scoping, not static
object binding...)
btw, note that you can get the same behaviour with today's Python:
s = I("some string here with ", variable, " in it")
that's only a little harder to type, is properly rendered by all existing IDEs and code
colorizers, is understood by existing code analysis tools, is trivial to extend with new
formatting operations, and is of course straightforward to override on all levels.
</F>
More information about the Python-3000
mailing list