anything new on the ternary operator?
Bob Gailer
bgailer at alum.rpi.edu
Mon Jul 7 09:21:14 EDT 2003
At 02:13 AM 7/7/2003 +0000, Russell Reagan wrote:
>"Bob Gailer" <bgailer at alum.rpi.edu> wrote
>
> > I was looking forward to having it.
>
>"Sean Ross" <sross at connectmail.carleton.ca> wrote
>
> > - (if C: x else: y) won the vote
>
>I'm still learning python, so don't flame too much :-)
>
>What is superior about using the proposed ternary operator instead of using
>the 'and' and 'or' operators to simulate inline logic?
The ternary op
if a: b else: y
would implement
if a:result = b
else: result = c
which is not identical to
result = a and b or c
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.492 / Virus Database: 291 - Release Date: 6/24/2003
More information about the Python-list
mailing list