Message345103
Bachsau,
to respond to the substance of your comments: it is not the *primary*
purpose of a compiler to teach, but compiler warnings on potentially
wrong behaviour is a long-standing tradition in many languages,
including Python.
This is not the first such warning in Python: it has warned on incorrect
assertions for a few releases now:
py> assert (flag, "error")
<stdin>:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?
Ideally a language should have no warts, gotchas or features which are
easy to misuse, but in practice that's not the case. Identity testing in
Python is, unfortunately, one of those features which are easy to
misuse, and it has real consequences.
If you go back to the very first post in the discussion which launched
this feature, Gregory points out that PyPy had to change their behaviour
to work around so many bugs in Python code from people wrongly using
identity tests over equality.
https://discuss.python.org/t/demoting-the-is-operator-to-avoid-an-identity-crisis/86
As the Zen says, "practicality beats purity" and this is a low-impact
change with no runtime cost that we expect will nevertheless help catch
many logical errors.
Apart from your aesthetic sense that the compiler shouldn't try to
educate users into using correct code rather than wrong code that works
by accident, do you have any objections to this feature?
Evidence of code that breaks because of this change is especially
valuable. |
|
Date |
User |
Action |
Args |
2019-06-10 02:02:15 | steven.daprano | set | recipients:
+ steven.daprano, barry, nascheme, rhettinger, gregory.p.smith, vstinner, jwilk, njs, serhiy.storchaka, xiang.zhang, Anthony Sottile, miss-islington, user30111 |
2019-06-10 02:02:15 | steven.daprano | link | issue34850 messages |
2019-06-10 02:02:15 | steven.daprano | create | |
|