PEP308: Yet another syntax proposal

Evan evan at 4-am.com
Mon Feb 10 22:03:08 EST 2003


Aahz wrote:
> Not yet.  So far, I haven't seen a clear justification for making this a
> language-level change.

I doubt that anyone who hasn't used Zope Page Templates extensively will 
find this persuasive, but in that realm (where Python expressions are 
possible, but statements are not) there has been a fair amount of pain 
suffered for lack of a short-circuiting conditional expression.

ZPTs *do* provide a non-short-circuiting "test(cond, t, f)" function, 
and when it is insufficient, use of the ugly _ and _ or _ idiom is 
required, since otherwise you end up having to write something like:

<tal:x condition="cond">
   <tal:x define="global v python:t()" />
</tal:x>
<tal:x condition="not:cond">
   <tal:x define="global v python:f()" />
</tal:x>
<p tal:content="v"></p>

...instead of

<p tal:content="python:(if cond: t() else: f())"></p>

As I say, though, non-ZPTer are unlikely to care :-)

Cheers,

Evan @ 4-am





More information about the Python-list mailing list