[Python-ideas] SyntaxWarning for for/while/else without break or return?
Masklinn
masklinn at masklinn.net
Fri Oct 9 23:46:42 CEST 2009
On 9 Oct 2009, at 23:07 , Georg Brandl wrote:
> 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
> some developers.
Indeed, there are numerous examples of such warnings in compilers:
warning about assignments in conditional contexts (which Python
forbids entirely, the ultimate hand-holding), warning about mismatches
between the format specifiers and the arguments of a `printf` or
`scanf`, warning about two-digit year formats, warning about
incomplete enumerations, warning about storing values but never
reading them, warning about allocated objects which are might not get
freed, warning about potential null-pointer dereferencings, warning
about overlapping patterns, warning about incomplete patterns, warning
about mixing tabs and spaces…
Python even has the last one already.
In all of those cases, the code is legal, and it might even have been
written that way on purpose.
More information about the Python-ideas
mailing list