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


Groups > comp.lang.python > #52126

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; '(except': 0.07; 'reason,': 0.07; 'assumed': 0.09; 'check,': 0.09; 'false,': 0.09; 'false.': 0.09; "wouldn't": 0.14; 'equal.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'aug': 0.22; 'skip:l 30': 0.24; 'helpful': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'invoke': 0.31; 'quite': 0.32; 'implemented': 0.33; 'maybe': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'skip:n 10': 0.64; 'skip:r 30': 0.69; 'sorry.': 0.91; 'why?': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ls/3OEBjBTCesmsO5jSIRdxnaXTaF523g0/2diEaj28=; b=Yc2tVQL8b3OmId9EORPb/mYrDfhBo/bGMCJV+9cXO4VQFal9iSkSo9Iaf+HafjLx+e 3fv4MDX6ARBIYEKdW+qUm9pn0Maff5hLvkIxOQmhNJwwxljxwfhUmm1UMH96TOClQTkb fuQwsM5zcYWxEz5VY26msU+GYZTl8Ep2sNnwc78s2K1FphAiVeE0KvoOu5jWJAMq59pi /+52xmOpiJ4PrlKgKIzFbAhzpszyi+jJUJ8ONElEecuuAzjbMpyeF+IweC9OdyzfSEdy HMf+8hSVj9eS4WCvdvxz/5Hovzc0/muaEO2xWd1bwaZLA3bo7Bz8ZIpOai1W9wGF8Zrn 4U7g==
MIME-Version 1.0
X-Received by 10.68.20.200 with SMTP id p8mr2664023pbe.122.1375868587980; Wed, 07 Aug 2013 02:43:07 -0700 (PDT)
In-Reply-To <CAJQX3Dx0Kg7QNW47SEEPZ8eLWZsCsfAciM0vdMucZ_nQ7yb-SA@mail.gmail.com>
References <51FED74E.6080003@markusrother.de> <CAPTjJmp=FzJO5pA2WgcojcK4UneAwx8qWDqrC4GeqjO9dxHgfg@mail.gmail.com> <CAJQX3Dx0Kg7QNW47SEEPZ8eLWZsCsfAciM0vdMucZ_nQ7yb-SA@mail.gmail.com>
Date Wed, 7 Aug 2013 10:43:07 +0100
Subject Re: Bug? ( () == [] ) != ( ().__eq__([]) )
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.310.1375868597.1251.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375868597 news.xs4all.nl 16012 [2001:888:2000:d::a6]:47402
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52126

Show key headers only | 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