FW: [Python-Dev] conditional expressions?

Martijn Faassen m.faassen at vet.uu.nl
Tue Oct 16 07:56:36 EDT 2001


Richard Jones <richard at bizarsoftware.com.au> wrote:
> 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.

Look for some examples elsewhere in the thread why I think conditional
expressions would still give rise to confusion about what belongs to them
and what doesn't. I suspect many users would do what I do in C expressions
whenever I'm unsure about the rules; add parens just to be sure. One of
the nice things about Python is that this kind of reaction right now doesn't
happen so often in expressions; the current rules seem to be easy enough
to grok.

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list