[Python-Dev] Adding a conditional expression in Py3.0
Terry Reedy
tjreedy at udel.edu
Wed Sep 21 03:21:26 CEST 2005
"John J Lee" <jjl at pobox.com> wrote in message
news:Pine.LNX.4.58.0509202331440.6289 at alice...
> The stricter form where you don't allow 'elif' will get used in more
> restricted circumstances, so gives less encouragement for widespread
> abuse
> of conditional expressions by people who don't like whitespace-based
> syntax.
I think 'abusiveness' is somewhat in the eye of the beholder here. In any
case, without 'elif', one could still chain expressions by writing
x = (if a then b else
(if c then d else
e))
which is even more Lispish. I personally think one () is enough and prefer
x = (if a then b
elif c then d
else e)
which is similar to how I wrote such things in C. Elif has the same
justification here as with the statement form, where it is also unnecessary
but saves nesting levels.
Terry J. Reedy
More information about the Python-Dev
mailing list