Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-13 Thread Sylvain Thénault
On 12 janvier 19:04, Carl Crowder wrote: > I think the point is that Pylint does not only say "this is wrong", but also > says "are you sure this is right?". These things are usually warnings but > perhaps 'code smell' is a better name. Because, in this case, the 'else' > isn't strictly necessar

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Peter Ludemann
On 12 January 2014 16:17, Kay Hayen wrote: > > Hello, > > thanks for all the replies. > > Of course I am aware that my use of the "else:" is different from the > "break" case > when it comes to "return". For return, the "else:" is not needed, as it > won't continue > the execution. > > > def

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Kay Hayen
Hello, thanks for all the replies. Of course I am aware that my use of the "else:" is different from the "break" case when it comes to "return". For return, the "else:" is not needed, as it won't continue the execution. > def _areConstants(expressions): > > for expression in expressi

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Marc 'BlackJack' Rintsch
On 12/01/14 18:45, Peter Ludemann wrote: > If you're asking about whether pylint should complain about the OP's > code, I think that it shouldn't -- in the semantics of for/else, return > and break are similar and rewriting OP's code to suppress the warnings > is not an improvement: > > def _a

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Carl Crowder
I think the point is that Pylint does not only say "this is wrong", but also says "are you sure this is right?". These things are usually warnings but perhaps 'code smell' is a better name. Because, in this case, the 'else' isn't strictly necessary, Pylint (correctly, in my opinion) raises a war

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Peter Ludemann
def _areConstants(expressions): return all(_isConstant(expression) for expression in expressions) def _isConstant(expression): return expression.isExpressionConstantRef() and not expression.isMutable() ? When I tried to understand the OP's code, I had to mentally step through the code an

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Ian Cordasco
Woops. Sorry for the confusion. I never end up using that particular construct so I never get it right. On Sun, Jan 12, 2014 at 9:18 AM, Carl Crowder wrote: > Ian, it's the opposite - 'else' is only triggered if *no* break statement is > encountered. > > > On 12 January 2014 16:12, Ian Cordasco

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Carl Crowder
Ian, it's the opposite - 'else' is only triggered if *no* break statement is encountered. On 12 January 2014 16:12, Ian Cordasco wrote: > I don't see any mesage from pylint in your email, could you post it again? > > Regardless, I think what you're disagreeing with is the language > specificati

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Carl Crowder
This came up once before, and I think the reasoning is that a for loop without a break statement means the 'else' is redundant. In your example, you can remove the 'else' and it would be functionally the same. On 12 January 2014 15:57, Kay Hayen wrote: > > Hello, > > often I write code like th

Re: [code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Ian Cordasco
I don't see any mesage from pylint in your email, could you post it again? Regardless, I think what you're disagreeing with is the language specification. The documentation specifies that the `else` is only triggered on breaks: http://docs.python.org/2/tutorial/controlflow.html#break-and-continue-

[code-quality] pylint: Else clause on a loop without break statement

2014-01-12 Thread Kay Hayen
Hello, often I write code like this: def _areConstants(expressions): for expression in expressions: if not expression.isExpressionConstantRef(): return False if expression.isMutable(): return False else: return True That is to search in