PEP 215 (was Re: [Python-Dev] PEP 216 (string interpolation) alternative EvalDict)

Paul Prescod paul@prescod.net
Tue, 15 Jan 2002 01:58:31 -0800


"Barry A. Warsaw" wrote:
> 
>...
> 
> Not to pick on Paul, but I'm having a hard time imagining how a newbie
> Python user being taught this new feature in his second hour will
> actually understand any of these rules.  

It's relatively simple. "You can do attribute access and function or
method calls. You can wrap things in parens do to more complicated
expressions." 

I would also be interested in a version of PEP 215 that merely required
parens all of the time. 

$"$(foo) $(5 + bar)"

I have always been nervous when I start new languages about how the
interpolation strings figure out where they end.

> ... And how will you later answer
> their questions about why Python has both $'' literals and '' % dict
> interpolation when it seems like you can do basically the same task
> using either of them?

One is for working with literals and the other for working with computed
strings that arise in your code. It's one of those things where you use
the simple way you are taught in class until you find a case where you
can't use it any more and then you'll understand why you need the
advanced way. Today's situation is that you are probably taught about
three or four ways in class because none of them is really particularly
"advanced". 

>...
> 
> I am definitely not convinced that Python desperately needs PEP 215.

I don't think anybody is convinced that Python desperately needs PEP
AFAIK, it hasn't been touched since July 2000. How could a 10 year old
language desperately need ANY syntactic sugar? If we survived until now
without something then we could probably survive another few years.

> I wonder if the same folks clamoring for it will be the same folks who
> raise their hands next month when asked again if they think Python is
> change too fast (naw, that won't happen :).

Ummm. Who is clamoring for this feature? We were presented with a newer
proposal to be compared with PEP 215. Some of us came to the conclusion
that PEP 215 is better than the new proposal. Nobody has, AFAIK,
proposed to complete or implement the PEP.

> How many of you use Itpl regularly?  If Python were so deficient in
> this regard, I would expect to see a lot of hands.  ....

The hassle of an extra dependency is without a doubt greater than the
hassle of working around Python in this regard. But then there are may
features in today's Python that fell into that category originally. Like
you could get a form of type/class unification from ExtensionClass. But
who would bother to install ExtensionClass just for that?

Anyhow, Mailman's code demonstrates that when the feature is provided at
low cost (i.e. no dependency), people use it. 

> is really not much more onerous, and certainly less jarring to my eye
> than all those $ signs.

This from mister print >>? ;)

 Paul Prescod