allow line break at operators
steve+comp.lang.python at pearwood.info
Wed Aug 10 10:32:05 CEST 2011
On Wed, 10 Aug 2011 04:05 pm Yingjie Lan wrote:
> :# the currently allowed way
> :x = (1+2+3+4+
> :# note the parentheses
> :I think this is sufficient.
> That works, but not in the most natural way--the way people are customed
> to...why require a pair of parenthis when we can do without them?
Because it is better to be explicit that the line is still open. An opening
parenthesis or bracket that hasn't been closed is an explicit sign that the
line is still open. An operator is not.
> the new way does not affect the old ways of doing things at all, it is
> fully backward compatible. So this just offers a new choice.
You say that as if having more choices is always good. It isn't. More
choices means more for people to learn, more complicated parser, more
options to consider, and more likelihood that errors will fail to raise
SyntaxError and instead go on to silently do the wrong thing. A new choice
should only be accepted when there is a clear and obvious benefit, not
merely because it will provide more choice.
Python is a programming language, not an ice cream shop.
>> Of course, the dot operator is also included, which may facilitate method
>> x = svg.append( 'circle' ).
If you are chaining six dots like that, you are in gross violation of the
Law Of Demeter. That is poor code, and should be discouraged, not
> :Also, I dislike this for the dot operator especially, as it can
> :obscure whether a method call or a function call is taking place.
> Again, this only offers a new choice, and does not force anybody to do it
> this way.
But it does force people to read it, because some people will use it, and so
others will have to suffer for their poor judgement.
More information about the Python-list