(a==b) ? 'Yes' : 'No'
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Tue Mar 30 13:11:29 EDT 2010
On Tue, 30 Mar 2010 10:08:31 -0700, John Nagle wrote:
>> Yes, Python has ternary operator-like syntax: return ('Yes' if a==b
>> else 'No')
>>
>> Note that this requires a recent version of Python.
>
> Who let the dogs in? That's awful syntax.
I used to think so to, but now I like it. It matches common English
syntax like:
"I'm going to the movies tonight, if I leave the office early, otherwise
I'll stay home and nitpick on Usenet."
--
Steven
More information about the Python-list
mailing list