For review: PEP 308 - If-then-else expression
Ian Bicking
ianb at colorstudy.com
Fri Feb 7 19:46:36 EST 2003
On Fri, 2003-02-07 at 18:00, jerf at compy.attbi.com wrote:
> Finally, and perhaps most controversially, ISTM that people asking for ?:
> are, with perhaps a few exceptions, new users of Python who expect it to
> be just like the last (or even "only") language they learned. If they want
> it that bad, in my experience it's probably because they're abusing it
> anyhow; most programmers go a very, very long time without using it even
> in languages that have it. One of Python's strengths is its stubborn
> refusal to let people hang themselves with it, unless they *really
> insist*.
This isn't true. While there certainly are people who are surprised
coming to Python that it doesn't have a ternary operator, there is also
a significant number of experienced Python programmers who would like to
have an if expression.
I and many other programmers have used ugly tricks with "and" and "or"
to achieve if-like results. In fact I believe those idioms are even
becoming more widely known over time. But everyone who uses them knows
they are *bad* idioms -- they are challenging to read, challenging to
write, and bug-prone. Yet we still do it! (even if infrequently)
So the point is: we are already hanging ourselves with Python. Because
the language can't express something people *want* to express, they work
around it with a bad hack. To me this is a very compelling reason (and
after formulating it more in my mind I feel much more strongly in favor
of this PEP). I think there is a strong empirically argument for this
enhancement.
--
Ian Bicking ianb at colorstudy.com http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625 / 773-275-7241
"There is no flag large enough to cover the shame of
killing innocent people" -- Howard Zinn
More information about the Python-list
mailing list