(a==b) ? 'Yes' : 'No'

Steve Holden steve at holdenweb.com
Tue Mar 30 19:43:41 EDT 2010


Lawrence D'Oliveiro wrote:
> In message <7316f3d2-bcc9-4a1a-8598-
> cdd5d41fd74b at k17g2000yqb.googlegroups.com>, Joaquin Abian wrote:
> 
>> (a==b) and 'YES' or 'NO'
>>
>> Yes, ugly
> 
> Why would you say that’s ugly?
> 
> By the way, you don’t need the parentheses.

But at the same time, if you don't *absolutely know* you don't need the
parentheses then the parentheses are a very good idea, so I applaud the
example as Pythonic while agreeing that it's ugly. A conditional
expression seems more natural.

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list