Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'interpreter': 0.05; '"""': 0.07; 'fallback,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'operands': 0.16; 'operation,': 0.16; 'operator.)': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'seems': 0.21; '(the': 0.22; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; '3.2': 0.31; 'comparison': 0.31; 'reflected': 0.31; 'received:84': 0.35; 'there': 0.35; 'false': 0.36; 'implement': 0.38; 'rich': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'name': 0.63; 'skip:n 10': 0.64; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'truth': 0.81; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=XqLDZz19 c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=K2DDQYBT4xIA:10 a=gdLhyB3e0vwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=zlaImjxt-LrTeE305ScA:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Mon, 05 Aug 2013 00:05:46 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Bug? ( () == [] ) != ( ().__eq__([]) ) References: <51FED74E.6080003@markusrother.de> In-Reply-To: <51FED74E.6080003@markusrother.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375657550 news.xs4all.nl 15945 [2001:888:2000:d::a6]:48558 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51942 On 04/08/2013 23:35, Markus Rother wrote: > Hello, > > The following behaviour seen in 3.2 seems very strange to me: > > As expected: > >>> () == [] > False > > However: > >>> ().__eq__([]) > NotImplemented > >>> [].__eq__(()) > NotImplemented > > And: > >>> bool(NotImplemented) > True > > Hence: > >>> bool(().__eq__([])) > True > >>> ( () == [] ) != ( ().__eq__([]) ) > True > > How/why can this be intended? > The docs say: """NotImplemented This type has a single value. There is a single object with this value. This object is accessed through the built-in name NotImplemented. Numeric methods and rich comparison methods may return this value if they do not implement the operation for the operands provided. (The interpreter will then try the reflected operation, or some other fallback, depending on the operator.) Its truth value is true. """