Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'raises': 0.07; 'subject:object': 0.07; 'assert': 0.09; 'subject:None': 0.09; '25,': 0.12; 'am,': 0.12; 'exception': 0.12; '2:38': 0.16; 'wrote:': 0.18; 'subject:not': 0.21; 'maybe': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'happen.': 0.23; 'sat,': 0.25; 'code': 0.25; 'message-id:@mail.gmail.com': 0.28; 'weird': 0.29; 'looks': 0.29; 'problem': 0.29; 'class': 0.29; 'false.': 0.30; 'subject:Test': 0.30; 'sun,': 0.30; 'equivalent': 0.31; 'values': 0.32; 'returning': 0.32; 'idea': 0.32; 'instead': 0.33; 'to:addr:python-list': 0.34; 'causing': 0.34; 'nobody': 0.34; 'received:209.85.212': 0.34; 'test': 0.35; 'problem.': 0.36; 'run': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'should': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'piece': 0.66; 'flip': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=P25Y8VKszDEGS464eA3FPSKKwG93ruVMMFP4P2nEXLk=; b=SfjPNUxPNH2cDhBZNhQ2IPEtg6JL1UtE5br9Zja+umlsVlzNCruD77PH79hXz8gK9f eqEqKVbKp3pYCweGYi8E69I+hzALHgXBb1ocISwFMur5d/E3x6adEdMjf3XAQakz3d0t U1lXOgAZgLrdrH5DB1QQQ8dlMNZ1sMxSUoszg= MIME-Version: 1.0 In-Reply-To: References: <0d80ce25-9e65-4216-b26c-b8ee40f989a3@q9g2000yqe.googlegroups.com> From: Ian Kelly Date: Sun, 25 Dec 2011 19:02:16 -0700 Subject: Re: Test None for an object that does not implement == To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324864969 news.xs4all.nl 6954 [2001:888:2000:d::a6]:49165 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17940 On Sun, Dec 25, 2011 at 2:38 AM, Nobody wrote: > On Sat, 24 Dec 2011 23:09:50 -0800, GZ wrote: > >> I run into a weird problem. I have a piece of code that looks like the >> following: >> >> f(...., a=3DNone, c=3DNone): >> =A0 =A0 assert =A0(a=3D=3DNone)=3D=3D(c=3D=3DNone) >> >> >> The problem is that =3D=3D is not implemented sometimes for values in a >> and c, causing an exception NotImplementedError. > > I have no idea how that can happen. If a.__eq__(None) returns > NotImplemented, the interpreter should flip the test and perform the > equivalent of None.__eq__(a), which will return False. Maybe the class has a misbehaved __eq__ that raises NotImplementedError directly instead of returning NotImplemented.