[Python-ideas] SyntaxWarning for for/while/else without break or return?
g.brandl at gmx.net
Fri Oct 9 23:07:30 CEST 2009
Gerald Britton schrieb:
> Based upon Guido's post in this thread, I think the chances of getting
> such a warning are between slim and none.
I don't read the post that way. Changing for/else's semantics, or removing
the else clause entirely won't happen, yes. But
> And, I'm very happy about
> that. In fact, I would be extremely unhappy if a program that has
> worked for 20 years (Guido's number, not mine) would suddenly start to
> spurt warnings just because I upgraded Python.
Sorry, but that happens often enough, e.g. when new keywords are added.
> Bad idea all round.
That's a very presumptuous statement. There is quite a heavy argument in
favor, namely prevention of bugs for people who misunderstand how for/else
works, see your initial examples. These bugs can be nasty, because they are
triggered by a corner case.
An example from a different language is mixing of && and || without parens,
which GCC warns about. The syntax is valid C, but I assume the warning exists
because the bugs it prevents weigh more than the irritation it causes in
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-ideas