[Python-ideas] SyntaxWarning for for/while/else without break or return?
Steven D'Aprano
steve at pearwood.info
Fri Oct 9 04:34:55 CEST 2009
More information about the Python-ideas mailing list
Fri Oct 9 04:34:55 CEST 2009
- Previous message: [Python-ideas] SyntaxWarning for for/while/else wi thout break or return?
- Next message: [Python-ideas] SyntaxWarning for for/while/else without break or return?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 9 Oct 2009 12:15:10 am Masklinn wrote: > The SyntaxWarning proposed would only be emitted on a `for: else:` > *without* a break as it's entirely equivalent to just deleting the > `else:` clause and dedenting the code it contains. No entirely -- the compiler generates different byte-code. > As far as outputting "spurious" messages in working programs, that's > the point of a warning isn't it? Tell the programmer that something > works, but might not do what one would like (or does nothing at all). Heavens no!!! What on earth gives you that idea? How can the compiler possibly know what you would like? And even if it could, it's the compiler's job to enforce the rules of the language, not to satisfy what people would like. Compiler warnings should never be spurious. Python warnings are used for meaningful warnings, such as deprecation warnings, not for stylistic ones like "by the way, you've used pass twice in a row, that's pointless". I don't want the compiler wasting my time with spurious warnings. If I want to run PyLint, I'll run PyLint. I don't want the compiler telling me I've defined a name and never used it, or declared a function that doesn't get called, or have code branches that can't possibly be taken, or anything else. I want it to compile, as fast as possible. The edit-compile-run cycle in Python is *very* lightweight, as it should be. When I want extra checking, I run PyLint, I don't want it every single time. -- Steven D'Aprano
- Previous message: [Python-ideas] SyntaxWarning for for/while/else wi thout break or return?
- Next message: [Python-ideas] SyntaxWarning for for/while/else without break or return?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list