[issue39746] Inappropriate short circuit relating to inequality comparison and membership test

Tim Peters report at bugs.python.org
Mon Feb 24 22:53:43 EST 2020


Tim Peters <tim at python.org> added the comment:

Orion, you're using the interface as intended :-)

While it's too late to change now, if Python started over from scratch I'd argue to leave "in" and "not in" out of this feature - chaining them is _usually_ an unintended behavior.

Then again, sometimes it is slightly useful.  For example, if I want to know if `n` is in a set of primes, but isn't even,

if 2 != n in some_set_of_primes:

does the job succinctly.  But not really "Pythonically", since even experienced Python programmers may scratch their heads when reading it :-(

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39746>
_______________________________________


More information about the Python-bugs-list mailing list