the PHP ternary operator equivalent on Python
Roy Smith
roy at panix.com
Sat Nov 19 00:36:35 EST 2005
In article <1132376750.855932.45470 at g47g2000cwa.googlegroups.com>,
"bonono at gmail.com" <bonono at gmail.com> wrote:
> 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 ?
I think the list comprehensions are going to be the death of readable
python programs.
More information about the Python-list
mailing list