Equivalent to (a ? b : c) ?

Preston Landers prestonlanders at my-deja.com
Mon Dec 20 16:47:45 EST 1999


In article <83lgkq$2q$1 at nnrp1.deja.com>,
  malraux at my-deja.com wrote:
> I remember seeing the Python equivalent to C's (a?b:c) inline if
> statement, but I can't find it for the life of me... can some kind
soul
> jog my memory for me please?

Hey,

Please correct me if I'm wrong, but there is no ternary conditional
operator in Python.  It would be kinda nice, but it's just syntactic
sugar.

Of course, there's nothing wrong with:

if a:
   b
else:
   c

Though this works too:

a and c or b

cheers,

---Preston


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list