A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033143.html below:

[Python-Dev] Re: Trinary Operators

[Python-Dev] Re: Trinary Operators [Python-Dev] Re: Trinary OperatorsShane Holloway (IEEE) shane.holloway@ieee.org
Thu, 06 Feb 2003 18:09:07 -0700
Gerald S. Williams wrote:
 > Compare this to the order of evaluation in the current
 > equivalent (parentheses for clarity only):
 >    (x and y) and 1 or 0
 >
 > or if you prefer:
 >    ((x and y) and [1] or [0])[0]


I was thinking that the semantics of "and" & "or" are the replacement 
for the trinary operator?  Since these operations always return the last 
evaluated subexpression (the same subexpression that short-circuits the 
evaluation), they can be used as Gerald outlines above.  It seems very 
consistent, logical, and understandable to me; but then again, I love 
the semantics of list compressions.  ;)

Thanks,
-Shane Holloway




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