Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52126

Re: Bug? ( () == [] ) != ( ().__eq__([]) )

References <51FED74E.6080003@markusrother.de> <CAPTjJmp=FzJO5pA2WgcojcK4UneAwx8qWDqrC4GeqjO9dxHgfg@mail.gmail.com> <CAJQX3Dx0Kg7QNW47SEEPZ8eLWZsCsfAciM0vdMucZ_nQ7yb-SA@mail.gmail.com>
Date 2013-08-07 10:43 +0100
Subject Re: Bug? ( () == [] ) != ( ().__eq__([]) )
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.310.1375868597.1251.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Aug 7, 2013 at 10:24 AM, Shiyao Ma <i@introo.me> wrote:
> Sorry. I don't quite get it. As you said, it first tries,
> leftOperand.__eq__(rightOperand) then if it returns NotImplemented, it goes
> to invoke rightOperand.__eq__(leftOperand). But for any reason, [] == ()
> returns false, why?

If neither of them has implemented a check, then it's assumed they're
not equal. It wouldn't be helpful for the == operator to return
anything other than True or False (except maybe NaN), so it returns
False.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Bug? ( () == [] ) != ( ().__eq__([]) ) Chris Angelico <rosuav@gmail.com> - 2013-08-07 10:43 +0100

csiph-web