
On Wed, Nov 24, 2021 at 07:15:58PM -0000, ehmatthes@gmail.com wrote:
One common error that I haven't seen discussed is bare logical comparisons. They're syntactically legal so they don't raise errors, but I have never seen a real-world use case for one.
You've never used the interactive interpeter? *wink* You're right, of course, that outside of the REPL it would be very unusual, and quite rare, to use `==` for its side-effects. Another usual use would be to overload the `==` operator for a DSL. They might be rare, but they are allowed, and the Python interpreter doesn't generally raise warnings for legal expressions used as statement just because they *might* be a mistake. Some compilers and interpreters raise a plethora of warnings, or errors, for legal but "weird" code that might be a mistake. But Python's interpreter tends to be a lot more easy-going, assuming you know what you are doing, and leaves it up to third-party linters. IDEs and code checkers to be more opinionated. Personally, I think that this is the right design. People can pick and choose which, if any, linter they use, and how strict they want it to be. But I can also understand that some people might want the interpreter to also have a built-in linter to flag mistakes. -- Steve