[Info] PEP 308 accepted - new conditional expressions

Fredrik Lundh fredrik at pythonware.com
Fri Sep 30 15:58:35 CEST 2005

Reinhold Birkenfeld wrote:

> after Guido's pronouncement yesterday, in one of the next versions of Python
> there will be a conditional expression with the following syntax:
> X if C else Y
> which is the same as today's
> (Y, X)[bool(C)]

hopefully, only one of Y or X is actually evaluated ?

> C and X or Y (only if X is True)

hopefully, "only if X is True" isn't in fact a limitation of "X if C else Y" ?

/... snip comment that the natural order is C, X, Y and that programmers that
care about readable code will probably want to be extremely careful with this
new feature .../


More information about the Python-list mailing list