Proposal: === and !=== operators

Chris Angelico rosuav at
Wed Jul 9 09:21:20 CEST 2014

On Wed, Jul 9, 2014 at 5:00 PM, Steven D'Aprano <steve at> wrote:
> Thoughts? Comments?

First thought: It will just add confusion. Currently, there are small
pockets of confusion surrounding the few cases where something's
non-reflexive, and there are occasional threads on the subject, like
we have now. Adding another pair of equality operators will mean that
everyone has to think "Do I want == or ===?", and we just need to look
at PHP and ECMAScript to see what happens - people pick the wrong
operator and have no end of subtle problems. There will be blog posts
around saying "always use === in Python", or "never use === in
Python", and everyone will get confused about how Python's === is
similar to and/or different from ECMAScript's and/or PHP's, and
ultimately, the only people who win out will be those who get paid to
write blog posts.

I think this is a big fat YAGNI. The two operators will differ in so
few situations that you may as well just define a few cases as "x is y
or x == y" instead of creating thew new operator; because really,
that's all that's happening here. (And the Py3 docs now use that kind
of notation to describe 'in'.) If you want fuzzy logic or three-valued
truth or anything, you probably know the types of the things you're
comparing, so it should be safe to use a method.


More information about the Python-list mailing list