A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/317227.html below:

[Info] PEP 308 accepted - new conditional expressions

[Info] PEP 308 accepted - new conditional expressionsReinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Fri Sep 30 14:25:35 EDT 2005
Fredrik Lundh wrote:
> 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 ?

(cough) Yes, sorry, it's not the same. The same would be

(C and lambda:X or lambda:Y)()

if I'm not much mistaken.

>> 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 .../

Yes, that was my comment too, but I'll not demonize it before I have used it.

Reinhold

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4