[Python-ideas] String interpolation for all literal strings
Nick Coghlan
ncoghlan at gmail.com
Thu Aug 6 17:20:20 CEST 2015
On 7 August 2015 at 00:28, Guido van Rossum <guido at python.org> wrote:
> Also, your phrase "contain arbitrary code" still sounds like a worry about
> code injection. You might as well worry about code injection in function
> calls.
Sort of - it's more a matter of hanging around with functional
programmers lately and hence paying more attention to the implications
of expressions with side effects. At the moment, there's no need to
even look inside a string for potential side effects, but that would
change with implicit interpolation in the presence of mutable objects.
I can't think of a good reason to include a mutating operation in an
interpolated string, but there's nothing preventing it either, so it
becomes another place requiring closer scrutiny during a code review.
If interpolated strings are always prefixed, then longer strings
lacking the prefix can often be skipped over as "no side effects
here!" - the worst thing you're likely to miss in such cases is a
typo.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list