Re: trinary operator - if then else

2007-04-25 Thread Nick Craig-Wood
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Michael >> > >> Does Python 2.4 support it? > > > > Not precisely, but you can *usually* get away with: > > > > a and b or c > > This is really bad advice, as long as you don't explain why it "usually" > works (and often enough not). This for exam

Re: trinary operator - if then else

2007-04-25 Thread Diez B. Roggisch
Michael >> >> Does Python 2.4 support it? > > Not precisely, but you can *usually* get away with: > > a and b or c This is really bad advice, as long as you don't explain why it "usually" works (and often enough not). This for example won't work: >>> False or '' and 0 '' The reason is that the

Re: trinary operator - if then else

2007-04-25 Thread Michael Bentley
On Apr 25, 2007, at 1:58 AM, Alchemist wrote: > What is Python's version for the trinary if..then..else operator? > > I want a one-liner such as > a?b:c > for the if..then..else control structure > if a > then b > else c > > Does Python 2.4 support it? Not precisely, but you can *usually*

Re: trinary operator - if then else

2007-04-25 Thread Peter Otten
Alchemist wrote: > What is Python's version for the trinary if..then..else operator? true_value if condition else false_value > Does Python 2.4 support it? No, it requires 2.5 or later. Peter -- http://mail.python.org/mailman/listinfo/python-list

trinary operator - if then else

2007-04-25 Thread Alchemist
What is Python's version for the trinary if..then..else operator? I want a one-liner such as a?b:c for the if..then..else control structure if a then b else c Does Python 2.4 support it? -- http://mail.python.org/mailman/listinfo/python-list