Paul Moore wrote:
On 3/7/06, Jeremy Hylton email@example.com wrote:
On 3/6/06, Alex Martelli firstname.lastname@example.org wrote:
On Mar 6, 2006, at 9:17 AM, Jim Jewett wrote: ...
I think that adding parentheses would help, by at least signalling that the logic is longer than just the next (single) expression.
level = (0 if "absolute_import" in self.futures else -1)
+1 (just because I can't give it +3.1415926...!!!). *Mandatory* parentheses make this form MUCH more readable.
Recent language features seem to be suffereing from excessive parenthesisitis.
Agreed. Mandatory parentheses purely for readability are ultimately futile - I bet I can write unreadable code even if the parens were required :-)))))))))))))))))))))))))
The parentheses around genexps were (AFAICT) different - without them, the grammar was ambiguous, so some way of disambiguating was needed.
+0 for mentioning parens around conditional expressions in PEP 8. But it's aready covered by the general "code should be readable" in my view.
Agreed - and often the best way to make a conditional expression readable is to not use it in the first place, which is a concept that an official policy on parentheses may mask. And then there's the question of how to parenthesise chained conditional expressions. Mandatory parentheses in that case would make me wonder if I was writing a certain language that isn't Python. . .
Given that the main reason PEP 308 was finally implemented was to provide OOWTDI for conditional expressions (instead of the handful of not-at-all-obvious and not-quite-right-either workarounds that had developed in their absence), I expect to see of rush of enthusiastic overuse of the new expression, which will eventually settle down as everyone remembers that not every problem is a nail to be hit with the shiny new hammer ;)