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

Robert Fendt no.spam at local.local
Tue Mar 30 14:16:09 EDT 2010


And thus spake Steve Holden <steve at holdenweb.com>
Tue, 30 Mar 2010 13:56:04 -0400:

> >> 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.
>
> Yes, that's deliberately awful syntax. Guido designed it that way to
> ensure that people didn't aver-use it, thereby reducing the readability
> of Python applications. Speaking purely personally I hardly ever use it,
> but don't dislike it.

In fact, the syntax just shouts 'do [...] unless' to me. And
that's so strong a Perl-ism I cannot quite express how ugly I
actually find it...

Regards,
Robert




More information about the Python-list mailing list