On 26/11/2021 00:12, Steven D'Aprano wrote:
On Wed, Nov 24, 2021 at 07:15:58PM -0000, [email protected] 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*
Very good point. You type `1==1`, it tells you `True`.
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.
+1. This just feels like it has "this is a job for linters" written all
over it. YMMV.
Best wishes
Rob Cliffe
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2SVYVNT2RRRATZ3YKSRZ7LG7LSF64ZV4/
Code of Conduct: http://python.org/psf/codeofconduct/