PEP 308: A PEP Writer's Experience - PRO
David Ascher
DavidA at ActiveState.com
Sun Feb 9 00:24:11 EST 2003
Tim Peters wrote:
>[Tim]
>
>
>>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"))
>>
>>or as:
>>
>> 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.
>>
>>
>
>[Andrew Koenig]
>
>
>>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)
you'd write
a * b+c
or
a * b + c
Much clearer, no?
--da
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
mailing list