[Python-ideas] SyntaxWarning for for/while/else without break or return?
g.brandl at gmx.net
Sun Oct 11 10:06:42 CEST 2009
Steven D'Aprano schrieb:
> And ridiculously:
>>>> assert (1, 2), "error"
> <stdin>:1: SyntaxWarning: assertion is always true, perhaps remove
> Why single out always-true tuples for a warning, when other always-true
> items are considered legitimate, even when there is no ambiguity about
> what the programmer meant? This sort of inconsistency makes little
> sense and should stand as a cautionary tale for people putting warnings
> in the compiler: sometimes the warning is *bad advice*:
>>>> assert 1, 2, "error" # remove the () like the compiler said
> File "<stdin>", line 1
> assert 1, 2, "error" # remove the () like the compiler said
> SyntaxError: invalid syntax
This would be a problem indeed if programmers were computers. Last time
I looked they were humans, and capable of not blindly following any
instruction the computer gives them. 
And even if they do, they obviously don't know how the assert statement
works, and need to revisit the docs.
 Note, only speaking of programmers here ;)
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