PEP 308: A PEP Writer's Experience - PRO

Tim Peters tim.one at comcast.net
Sat Feb 8 14:03:40 EST 2003


[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.






More information about the Python-list mailing list