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/2001-April/069663.html below:

Conditional operator in Python?

Conditional operator in Python?Ben Wolfson wolfson at midway.uchicago.edu
Sun Apr 1 00:25:44 EST 2001
In article <3AC6B9C5.68EFC041 at alcyone.com>,
Erik Max Francis  <max at alcyone.com> wrote:
>Emile van Sebille wrote:
>
>> Yes, it comes up.  Generally, except for short-circuiting, the
>> solutions
>> follow:
>> 
>> >>> 1 and 2 or 3
>> 2
>> >>> 0 and 2 or 3
>> 3
>
>Yeah, but the short-circuiting exceptions are what make that construct
>not worth using, since if used identically as a replacement for a
>conditional expression, it won't work when a is 0 (or any other
>expression that evaluates to false).

Easily, if unreadably, solved: (condition and (a,) or (b,))[0]



-- 
Barnabas T. Rumjuggler
You do not use a macintosh instead you use a tandy
Kompressor break your glowstick Kompressor eat your candy

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