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/077905.html below:

Conditional operator in Python?

Conditional operator in Python? Conditional operator in Python?Duncan Booth duncan at rcp.co.uk
Mon Apr 2 06:27:37 EDT 2001
Sheila King <sheila at spamcop.net> wrote in 
<of4dct0nul0rc6ik758gb1io3i099q1bgo at 4ax.com>:

>So, to return the max of a or b I could do
>
>return  ( a > b ) and a or b
>
>Here is an interpreter session:
>
>>>> a = 5
>>>> b = 3
>>>> (a > b) and a or b
>5
>>>> a = 2
>>>> b = 12
>>>> (a > b) and a or b
>12
>>>> 
>

Please don't do this, as it doesn't do what you think.

>>> a = 0
>>> b = -5
>>> (a > b) and a or b
-5

and consider that one of the common uses for a max function is to set a 
lower bound of 0 on a calculation.

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