On 04/24/2018 08:19 AM, Yury Selivanov wrote:
Yes, because I'm trying to think about this from a pragmatic side of things. My question to myself: "what syntax could I use that would prevent me from making '=' vs '==' mistake when I code?" To me, the answer is that I usually want to compare local variables.
I think we need to disambiguate between typo-typos and thinko-typos. I suspect the vast majority of the '=' bugs are not due to the programmer /thinking/ the wrong operation, but of their hands/keyboards not /entering/ the right symbols; having a legal operator ("==") degrade into another legal operator ("=") that looks similar but means incredibly different things is a trap that we should not add to Python.
You might say that we have the same problems with ">=", "<=", and "!=". We don't with "!=" because neither "!" nor "=" can stand alone and would fail. We only have it partially with "<=" and ">=" because missing the angle bracket results in failure, but missing the "=" results in a working statement -- but that statement is still the same type of operation and is easier to debug when boundary cases fail.
When I compare to variables from outer scopes they *usually* are on the *right* side of '=='.
You mean something like if 2 == x: ? I never write code like that, and I haven't seen it, either. -- ~Ethan~ _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com