For review: PEP 308 - If-then-else expression

Mike Meyer mwm at mired.org
Sat Feb 8 04:09:49 CET 2003


Andrew Koenig <ark at research.att.com> writes:

> I think that if you like list comprehensions and lambda expressions,
> you'll probably like PEP 308; if you don't, you probably won't.

I like lambdas, and some forms of list comprehensions - because they
make the resulting code more readable.

I don't like PEP 308, because I'm not convinced that it many things
more readable. I'm sure there are cases where it does, but are there
enough of them to justify it?

Lambdas and list comprehensions both start with something that sets
them apart in the expression. Lambda's with lambda, and list
comprehensions start out looking like a list. If you took the initial
'[' off of list comprehensions, they wouldn't be nearly as readable.

While I don't object to the idea of a ternary operator per se, I find
this one objectionable. The problem is that it does magic, but you
don't know that until you've read the first expression. I think that
results in an overall lowering of the readability of the code.

I'd say no.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.




More information about the Python-list mailing list