Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'will,': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '-tkc': 0.16; 'equality.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'is).': 0.16; 'roy': 0.16; 'subject:operators': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'y):': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'not,': 0.20; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; '(this': 0.29; "d'aprano": 0.31; 'equality': 0.31; 'steven': 0.31; 'test': 0.35; 'add': 0.35; 'false': 0.36; 'charset:us-ascii': 0.36; 'too': 0.37; 'does': 0.39; 'either': 0.39; 'biggest': 0.67; 'smith': 0.68; 'jul': 0.74; 'you:': 0.81; 'received:50.22': 0.84; 'subject:Proposal': 0.91 Date: Wed, 9 Jul 2014 13:05:22 -0500 From: Tim Chase To: Steven D'Aprano Subject: Re: Proposal: === and !=== operators In-Reply-To: <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404929192 news.xs4all.nl 2901 [2001:888:2000:d::a6]:48576 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74269 On 2014-07-09 12:48, Steven D'Aprano wrote: > On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote: > > > We would have *three* ways to compare for equality (==, ===, and > > is). > > `is` does not, never has, and never will, be a test for equality. > > py> x = [] > py> y = [] > py> x is y > False I too am in the -1 category for adding an extra operator-suite because of the confusion it will add (this is one of my biggest pet peeves with PHP/JS). If you want to compare things in a NaN-aware way, you can either spell it out explicitly: if x == y or (math.isnan(x) and math.isnan(y)): do_stuff() or create a wrapper function to do that for you: def equalish(x, y): return x == y or (math.isnan(x) and math.isnan(y)) if equalish(w, z): print("yep") else: print("nope") -tkc