For review: PEP 308 - If-then-else expression
Carlos Ribeiro
cribeiro at mail.inet.com.br
Fri Feb 7 20:22:20 EST 2003
Andrew,
I'll pick just one example...
On Saturday 08 February 2003 12:49 am, Andrew Dalke wrote:
> However, modifying the code is much easier.
>
> descr = b** 2 - 4*a*c
> if descr > 0:
> root_type = "real"
> elsif descr == 0:
> root_type = "duplicate"
> else:
> root_type = "imaginary"
> print "descriminate =", descr
> print "roots are", root_type
I don't think that the code above is much clearer than the one-liner with the
ternary operator. What I see is that you may be used to sequential
programming, and so, specifying every step seems to be the "right way of
doing it" for you. In my opinion, the only thing that the code above buys you
is the ability to follow it step by step, but that does not mean it's much
clearer - only that it works a few abstraction layers below the one-liner
with the ternary operator.
In my opinion, the best thing to do right now is to wait a few days for things
to settle down. I'm sure that many people that reacted against it today will
get used to the idea fairly quickly, specially if we come up with a slightly
better idiom (this one is quite good, but some good candidates for
improvement have appeared today, and more will come).
There is always reaction to change. Sometimes we get used to the new stuff so
fast that we can't even understand why did we react first place.
Carlos Ribeiro
cribeiro at mail.inet.com.br
More information about the Python-list
mailing list