Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45210
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <titanix88@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'output': 0.05; '"""': 0.07; '-*-': 0.07; 'subject:bug': 0.07; 'utf-8': 0.07; 'advance': 0.07; 'coding:': 0.09; 'val': 0.09; 'python': 0.11; 'def': 0.12; 'bug': 0.12; '__future__': 0.16; 'reproduce': 0.16; 'subject:python3': 0.16; 'import': 0.22; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'class': 0.32; 'to:name :python-list': 0.33; 'skip:_ 10': 0.34; 'received:google.com': 0.35; 'false': 0.36; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'situation': 0.65; 'behavior': 0.77 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=D6MvZNA3SPzefyV12aCamQYy7759ME5rJ2Lvfnz5ptg=; b=snrm7Ybla47zSuCOooBgns+erYLEfMwcohUWNN4gJnw18G+OsgFCHJhndGbuqewaGW W4jq0rsdJg9pxz/tX+mkmttg9OBBv3SlJ31LEcASFyc34u+PnOjjNYVD7TGiIGFAHcRh 5ywnGQF0zFkE/wmnE6V3maGBIoTzQ60DAz58nvUfskcO7MeEKnCardjr2rcGc6f8Oam9 zmPxKB8uJvlcJVCRDCMdDaXmzKxwXlI1Erc2bDgYyVxQw/TsTh0RLaXnF3eTw4ueRczR O5P1rL4U6gWK+QeNtTSSn7GcjnSCI3TQrBBcMKd3+EgeKKQK5SLaD7NPsm1ajTEzOmiO YBmw== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.237.106 with SMTP id vb10mr20868242pbc.131.1368400996468; Sun, 12 May 2013 16:23:16 -0700 (PDT) |
| Date | Mon, 13 May 2013 05:23:16 +0600 |
| Subject | Differences of "!=" operator behavior in python3 and python2 [ bug? ] |
| From | "Mr. Joe" <titanix88@gmail.com> |
| To | python-list <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.1603.1368401007.3114.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1368401007 news.xs4all.nl 15895 [2001:888:2000:d::a6]:50355 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45210 |
Show key headers only | View raw
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 -
"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
class DemoClass(object):
def __init__(self, val):
self.val = val
def __eq__(self, other):
return self.val == other.val
x = DemoClass('a')
y = DemoClass('a')
print("x == y: {0}".format(x == y))
print("x != y: {0}".format(x != y))
print("not x == y: {0}".format(not x == y))
"""
In python3, the output is as expected:
"""
x == y: True
x != y: False
not x == y: False
"""
In python2.7.3, the output is:
"""
x == y: True
x != y: True
not x == y: False
"""
Which is not correct!!
Thanks in advance for clarifications.
Regards,
TB
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Differences of "!=" operator behavior in python3 and python2 [ bug? ] "Mr. Joe" <titanix88@gmail.com> - 2013-05-13 05:23 +0600
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Alister <alister.ware@ntlworld.com> - 2013-05-13 09:59 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Fábio Santos <fabiosantosart@gmail.com> - 2013-05-13 18:26 +0100
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Ned Batchelder <ned@nedbatchelder.com> - 2013-05-13 14:08 -0400
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Chris Angelico <rosuav@gmail.com> - 2013-05-14 04:15 +1000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Fábio Santos <fabiosantosart@gmail.com> - 2013-05-13 19:28 +0100
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Alister <alister.ware@ntlworld.com> - 2013-05-13 21:17 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Fábio Santos <fabiosantosart@gmail.com> - 2013-05-13 22:48 +0100
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-13 23:53 +0100
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Dave Angel <davea@davea.name> - 2013-05-13 19:22 -0400
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-14 05:09 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-14 19:01 -0400
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-15 00:15 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-14 22:20 -0400
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Andrew Berg <bahamutzero8825@gmail.com> - 2013-05-13 18:27 -0500
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-13 17:32 -0600
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-14 05:21 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Alister <alister.ware@ntlworld.com> - 2013-05-15 14:41 +0000
Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ] Chris Angelico <rosuav@gmail.com> - 2013-05-14 17:31 +1000
csiph-web