[ZPT] If/else?

Guido van Rossum guido@digicool.com
Thu, 10 May 2001 12:01:42 -0400


> Guido van Rossum wrote:
> > Our latest proposal will remove these again, and add a
> > simpler mechanism instead: "x | y | z" will evaluate to the path x if
> > it is defined and non-empty, otherwise to y if it is defined and
> > non-empty, otherwise to z (which must be defined, but may be empty).
>   ^^^^^^^^^
>   should that be just 'empty'?

No, y must also be defined and non-empty in order to qualify.  You can
do x|y|z|a|b|c and it tries each of them in turn until it finds one
that exists and is non-empty -- except the last one may be empty
because there's no alternative, but it must still be defined.

> Yeah, I'd agree with that, but it shouldn't do a blanket exception
> catch either, like dtml-if used to ;-)

You better tell that to Evan and Jim!  It looks like we should spell
out exactly which exceptional conditions are equivalent to "false"
here and which ones aren't!  (There's always on-error for catching
more severe errors.)

> > For those cases where the |-separated sequence doesn't have enough
> > expressive power, we propose to fall back on Python expressions
> > ("python:<expression>") which are all-powerful,
> 
> Are these in there already? I hope not, if fact, please god no!!! :-(

Yes, they have been part of the TALES design and implementation from
the start.  What's wrong with them?

> 'expr=' was the beginning of the end for DTML and python directly in
> ZPT is metaphorically equivalent, for me, to allowing {} as a block
> delimiter in python
> ;-)

Please give a less emotional explanation.

(I'll leve the rest for Evan to answer -- I'm not qualified.)

--Guido van Rossum (home page: http://www.python.org/~guido/)