the PHP ternary operator equivalent on Python
bonono at gmail.com
bonono at gmail.com
Sat Nov 19 00:05:50 EST 2005
Steven D'Aprano wrote:
> WHY WHY WHY the obsession with one-liners? What is wrong with the good old
> fashioned way?
>
> if cond:
> x = true_value
> else:
> x = false_value
>
> It is easy to read, easy to understand, only one of true_value and
> false_value is evaluated. It isn't a one-liner. Big deal. Anyone would
> think that newlines cost money or that ever time you used one God killed a
> kitten.
>
How do you put this block into list comprehension or generator
expression ? Why the obsession of these block style ?
More information about the Python-list
mailing list