PEP 308: A PEP Writer's Experience - PRO
DavidA at ActiveState.com
Sun Feb 9 06:24:11 CET 2003
Tim Peters wrote:
>>OTOH, when I read Micahel's post, I had no idea whether
>> print "x = " + x.getDisplayString() if x else "None"
>>would group as:
>> print ("x = " + (x.getDisplayString() if x else "None"))
>> print (("x = " + x.getDisplayString()) if x else "None")
>>and I didn't even know which way he *intended*. Spelled with an if-
>>statement instead, the intent is obvious instead of a puzzle.
>>Or spelled with an extra pair of parentheses.
>I didn't think so: that's why there's also extra horizontal whitespace in
>the above, to put the pieces that group together closer to each other.
>Either could be improved by dropping the outermost parens, although
>experience with Perl gives me a confusing impression then too because of the
>"if near the end of a line" business.
I think that Python precedence rules should use a count of whitespace,
it would make life a lot simpler.
So instead of:
a * (b + c)
a * b+c
a * b + c
Much clearer, no?
PS: the weight of tabs and escaped newlines in the precendence algorithm
is left as an exercise for the reader.
More information about the Python-list