The ternaery operator

Tobiah toby at tobiah.org
Thu Mar 16 11:07:19 EDT 2017


On 03/16/2017 01:12 AM, Gregory Ewing wrote:
> Stefan Ram wrote:
> 
>> a if c else b
>>
>>   Guido has invented something totally new. Why?
> 
> It's arguably closer to the way you would say such a
> thing in English.
> 
> Consider the following sentences:
> 
> "I wear my red shirt if it's Tuesday, else my green one."
> 
> "I wear if it's Tuesday my red shirt, else my green one."
> 
> Which one sounds more natural?
> 

Actually, I see where now you are coming from:

  I wear (if a then b else c)

as opposed to

  I wear (b if a else c)


More information about the Python-list mailing list