[Guido] > After a fruitful discussion on python-ideas I've decided that it's fine to > break lines *before* a binary operator. It looks better and Knuth recommends > it. > ... > Therefore it is permissible to break before or > after a binary operator, as long as the convention is consistent > locally. For new code Knuth's style is suggested. > > Some examples of code breaking before binary Boolean operators:: > > class Rectangle(Blob): > > def __init__(self, width, height, > color='black', emphasis=None, highlight=0): > if (width == 0 > and height == 0 > and color == 'red' > and emphasis == 'strong' > or highlight > 100): > raise ValueError("sorry, you lose") > if (width == 0 and height == 0 > and (color == 'red' or emphasis is None)): > raise ValueError("I don't think so -- values are %s, %s" % > (width, height)) > Blob.__init__(self, width, height, > color, emphasis, highlight) > Note that this code still breaks a line after a binary operator (the string formatting "%" operator in the 2nd ValueError call). But it's perfectly clear the way it is. Good taste can't be reduced to rules ;-)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4