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
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
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
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
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
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
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
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
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
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-
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
11 matches
Mail list logo