Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.042 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.02; 'operator': 0.03; 'method.': 0.07; 'subject:bug': 0.07; 'meaningful': 0.09; 'python': 0.11; 'bug': 0.12; '__ne__': 0.16; 'opposite': 0.16; 'reproduce': 0.16; 'subject:python3': 0.16; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.27; 'joe': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'implemented': 0.33; 'older': 0.33; 'received:209.85': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'received:209': 0.37; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; '12,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'situation': 0.65; 'default': 0.69; 'special': 0.74; 'behavior': 0.77; 'returns.': 0.84; '2013': 0.98; 'mr.': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=3JXOUuf+Xj3g2WUTt3NmlwOByZhZOsYTFmNSTrRH6Co=; b=HeeD4v2MWO7+ePiECjs5u4pFmoF0xD0xLFlFpA9B6y24mFqZHCbGV5kN4szKb6r5Sf vDXaZl4eZVFGCEHZNLlBB5Fu5JxssZly1L8EdZe86PcSf+hoJnjbjZUl17DFON/BbK9s lRJdBWrwfmFHmusgpgcpkvGHN2Fj3x8P612tMsilKk5yoaga4bAA5Cf1Sxt/zOFDTz8A +PpnVdTLkCgbGHY2aOjRx8ELOc86fWae4/s1EuslXcKBgvjvquRaUtH/jhU3M6e8OhwY K6420938mUOeAD9C4kmjfc7H7tu5b7aPea2KKKMky/P6huk7rel9vF20JZ3xF8xbRnbD 5XEA== X-Received: by 10.66.250.230 with SMTP id zf6mr27786677pac.153.1368402057961; Sun, 12 May 2013 16:40:57 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Sun, 12 May 2013 17:40:17 -0600 Subject: Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368402067 news.xs4all.nl 15923 [2001:888:2000:d::a6]:60713 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45213 On Sun, May 12, 2013 at 5:23 PM, Mr. Joe wrote: > I seem to stumble upon a situation where "!=" operator misbehaves in > python2.x. Not sure if it's my misunderstanding or a bug in python > implementation. Here's a demo code to reproduce the behavior - The != operator is implemented by the __ne__ special method. In Python 3, the default implementation of __ne__ is to call __eq__ and return the opposite of whatever it returns. In Python 2, __ne__ calls the older __cmp__ method instead, which is no longer meaningful in Python 3.