Draft PEP: string interpolation with backquotes

Fernando Pérez fperez528 at yahoo.com
Sat Dec 1 22:02:34 CET 2001


phil hunt wrote:

>>
>>        "x is $x, f(x) is $f(x)"
>>
>>This to me is readable, unambiguous and very useful.
> 
> To me it implies the same as:
> 
>    "x is %(x)s, f(x) is %(f)s(x)" % { 'x': x, 'f': f}
> 
No. $_whatever_ means: fully evaluate _whatever_, as far as it can be 
evaluated, and put its value in there. So it gives an interpolation 
syntax which is in fact much cleaner than perl's, with much less need 
for braces and name protection.

> 
> What's wrong with the existing way of doing things with "%"?
> 

Try using the  existing syntax for really complex cases. In the post 
you quote, I explicitly showed what the current options are, and 
their flaws. For one-liners it doesn't matter. The problem is 
*scalability*. As always, easy problems can be solved easily. The 
question is: is the tool good enough for solving the hard problems? 
If you read my complete post, either you'll agree that it doesn't or 
you'll give me a counter argument. But read and argue on the whole 
post, not just a snippet of it.

f.




More information about the Python-list mailing list