[ZPT] If/else?

Evan Simpson evan@digicool.com
Thu, 10 May 2001 12:12:12 -0400


From: "Guido van Rossum" <guido@digicool.com>
> i.e. the three arguments are evaluated before testing (since this is
> implemented as a regular function).  (Of course, Evan "bytecodehacks"
> Simpson might have a different implementation in mind. :-)

I wouldn't mind using RestrictedPython's AST stuff to convert this into a
lazy evaluator.  I would *love* it if Python itself defined '(if a: b else:
c)' as a syntactic construct (instead of Eric's proposed 'a ? b : c', for
instance).

> > Or is it more akin to the "x|y|z" construct for path expressions,
> > returning the first one that is defined and non-empty?
>
> Hm, that should probably be a different function.

Since path() is meant to behave exactly like a path expression, you should
be able to write path('x | y | x').

Cheers,

Evan @ digicool