conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))

Tim Peters tim.one at home.com
Mon Oct 15 15:05:16 EDT 2001


[John Roth]
> Huh? The purpose of the new syntax is to have a conditional
> facility within an expression. If a new line begins with the keyword
> 'if', then that is a statement. A conditional if only makes sense _inside_
> an expression, hence it doesn't look like there is an issue.

Any Python expression can be used as a statement (think of what you type at
an interactive shell).

> A bigger issue from a usability standpoint is the lack of a
> clear end to the scope of a given 'if', leading to the infamous
> dangling 'else' problem.

The 'else' clause is not optional in a conditional expression, so the
"dangling else" problem can't arise.





More information about the Python-list mailing list