FW: [Python-Dev] conditional expressions?

Richard Jones richard at bizarsoftware.com.au
Mon Oct 15 20:24:26 EDT 2001


On Tuesday 16 October 2001 10:12, Martijn Faassen wrote:
>   * Perhaps one can lose the parens in the conditional expression.
>     Can one? What is the rule? Is the rule easy to remember? Of course
>     I think it'd look less readable still without the parens...

Guido has stated that the parens are only required to disambiguate the 
expression. The main case that's out of the ordinary (ie currently there are 
situations where we need to disambiguate expressions, and this is a new one) 
is where one of these conditional expressions occurs at the start-of-line. 
The "if" is then a statement unless forced to be an expression. And without 
the parens, a SyntaxError will result.


     Richard




More information about the Python-list mailing list