PEP 308: Alternative conditional operator forms
Andrew Koenig
ark at research.att.com
Tue Feb 11 16:29:11 EST 2003
>> if C: print x
>> else: print y
>>
>> is correct whereas
>>
>> (if C: print x
>> else: print y)
>>
>> would be a syntax error!
Dave> Yes, but for at least two good reasons: multiline expressions in
Dave> Python require '\' to join the lines (and this shold be no
Dave> exception) and 'print' is a statement - there's no risk for
Dave> hidden bugs because the code won't even compile (and that's a
Dave> good thing).
Multiline expressions don't require '\' to join them if the newline
appears at a point where parentheses are unbalanced.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list