[Python-Dev] Trinary Operators (original) (raw)
Guido van Rossum guido@python.org
Thu, 06 Feb 2003 14:49:23 -0500
- Previous message: [Python-Dev] Trinary Operators
- Next message: [Python-Dev] Trinary Operators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
If this is just for fun, why stop with just "trinary"?
(Which BTW is a non-word; the correct term is "ternary".)
How about one of the following (depending on ease of parsing)? These look even more like list comprehension.
x = (e1 if c1 e2 if c2 e3 if c3 ... else d)
Doesn't parse. The concatenation of two expressions is not always distinguishable from a single expression: consider c1 = f and c2 = (1, 2).
x = (e1 if c1 else e2 if c2 else e3 if c3 ... else d)
That works.
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Trinary Operators
- Next message: [Python-Dev] Trinary Operators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]