[Python-Dev] PEP 216 (string interpolation) alternative EvalDict

Paul Prescod paul@prescod.net
Mon, 14 Jan 2002 18:01:52 -0800


Skip Montanaro wrote:
> 
>...
> 
> So?  There are some things Perl does better than Python, some things Python
> does better than Perl.  

It doesn't have anything to do with competing with Perl. It is just
about learning from things that other languages do better (in this case
simpler) than Python. This feature came from the Bourne shell and is
also present in DOS batch, TCL, Ruby, PHP. 

Python's "%" is much better than nothing (which is what Javascript has)
but it is still a pain. First you use it with positional arguments and
then realize that is getting confusing so you switch to dictionary
arguments and then that gets unweildy because you're just declaring new
names for existing variables so you use vars(). But then you want to
interpolate the result of a function call or expression. So you have to
set up a one-time-use variable.

PEP 215 (which I did not write!) unifies all of the use cases into one
syntax that can be taught in ten minutes. The % syntax is fine for
totally different use cases: printf-style formatting and interpolation
of strings that might be generated at runtime.

 Paul Prescod