[Python-Dev] PEP 292, Simpler String Substitutions
Guido van Rossum
guido@python.org
Thu, 20 Jun 2002 00:23:26 -0400
> `...` is already in python though.
But not in this form.
> Better to generalise and/or extend an already existing construct than to
> add a new one, I would assert.
Only if that construct is successful. `...` has a bad rep -- people
by and large prefer repr().
> Youre also right about `...` being less visible than other pairs of
> delimiters.
>
> I think, though, that if modifying the % notation, that the requirement
> should be for delimiters that are not parentheses, and ones that
> wouldn't interfere with putting expressions between them. This would
> allow for eval()ing the content between the delimiters.
You could do that with ${...} if it skipped nested {...} inside, which
I plan to implement as an (initially secret) extension. That should
be good enough. If you try to put string literals containing { or }
inside ${...} you deserve what you get. :-)
Still, this wouldn't work:
x = 12
y = 14
print "$x times $y equals ${x*y}".sub()
You'd have to pass a special magic dict (which I *won't* supply).
--Guido van Rossum (home page: http://www.python.org/~guido/)