[Info] PEP 308 accepted - new conditional expressions

Richie Hindle rjh at cyberscience.com
Fri Sep 30 10:19:02 EDT 2005


[Fredrik]
> > X if C else Y
> 
> hopefully, only one of Y or X is actually evaluated ?

Yes.  From Guido's announcement at
http://mail.python.org/pipermail/python-dev/2005-September/056846.html:

> The syntax will be
> 
>     A if C else B
> 
> This first evaluates C; if it is true, A is evaluated to give the
> result, otherwise, B is evaluated to give the result.

-- 
Richie Hindle
richie at entrian.com



More information about the Python-list mailing list