Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed0.kamp.net!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!62.179.104.142.MISMATCH!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'example:': 0.03; 'subject:object': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:None': 0.09; 'def': 0.13; 'method.': 0.15; 'none"': 0.16; 'wrote:': 0.18; 'subject:not': 0.21; 'header:In-Reply-To:1': 0.22; 'itself,': 0.23; "shouldn't": 0.23; 'import': 0.27; 'compare': 0.28; 'random': 0.28; 'print': 0.29; 'pm,': 0.29; 'class': 0.29; 'subject:Test': 0.30; 'header :User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'there': 0.33; 'to:addr:python-list': 0.34; 'nobody': 0.34; 'something': 0.35; 'unless': 0.35; 'equal': 0.36; 'received:au': 0.36; 'none': 0.37; 'except': 0.37; "there's": 0.37; 'not,': 0.37; 'doing': 0.38; 'received:org': 0.38; 'should': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.40; 'results': 0.63; '__eq__(self,': 0.84; 'other):': 0.84; 'received:110': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lie Ryan Subject: Re: Test None for an object that does not implement == Date: Sun, 25 Dec 2011 22:10:28 +1100 References: <0d80ce25-9e65-4216-b26c-b8ee40f989a3@q9g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 110-175-240-90.static.tpgi.com.au User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324811442 news.xs4all.nl 6893 [2001:888:2000:d::a6]:40951 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17880 On 12/25/2011 08:38 PM, Nobody wrote: > nothing should compare equal to None except for None itself, so "x is None" > and "x == None" shouldn't produce different results unless there's a > bug in the comparison method. not necessarily, for example: import random class OddClass: def __eq__(self, other): return [True, False][random.randint(0, 1)] x = OddClass() print x == None print x == None print x == None print x == None print x == None Now, whether doing something like that is advisable or not, that's a different question; however nothing in python states that you couldn't have something that compare equal to None whether there is a bug or not in the comparison method.