Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'string': 0.09; '===': 0.09; 'converted': 0.09; 'type,': 0.09; 'python': 0.11; 'wrote': 0.14; '"""if': 0.16; 'coerced': 0.16; 'evaluates': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'operators,': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'record,': 0.16; 'skip:n 50': 0.16; 'surprises': 0.16; 'wrote:': 0.18; 'numerical': 0.19; 'header:User-Agent:1': 0.23; 'url:02': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'comparison': 0.31; 'equality': 0.31; 'operators': 0.31; 'not.': 0.33; 'moment': 0.34; 'form.': 0.35; 'received:84': 0.35; 'but': 0.35; 'false': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'skip:a 30': 0.61; 'numbers': 0.61; 'skip:n 10': 0.64; 'header :Reply-To:1': 0.67; 'frank': 0.68; 'url:11': 0.68; 'reply-to:no real name:2**0': 0.71; 'url:2011': 0.75; 'discovered': 0.83; 'reply-to:addr:python.org': 0.84; 'url:php': 0.85 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=PIY2p5aC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=LqG8EI-UCiYA:10 a=9Lj92nWf6HwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=_Q_BDBVkwOwA:10 a=kZ7UWmmPAAAA:8 a=RA7hJJdoAAAA:8 a=jXVu7m8nAAAA:8 a=67BIL_jfAAAA:8 a=vgYuZmFGI6ynuH9sn6AA:9 a=VU3zJFPJVLIE0z1E:21 a=rudRCl3_M18fymoO:21 a=wPNLvfGTeEIA:10 a=h8MLz70XGbQA:10 a=pyH5b1fOeEsA:10 X-AUTH: mrabarnett:2500 Date: Thu, 10 Oct 2013 12:10:40 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: I am never going to complain about Python again References: <52562ee3$0$2931$c3e8da3$76491128@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381403445 news.xs4all.nl 15878 [2001:888:2000:d::a6]:49929 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56559 On 10/10/2013 09:23, Frank Millman wrote: > > "Steven D'Aprano" wrote in message > news:52562ee3$0$2931$c3e8da3$76491128@news.astraweb.com... >> Just came across this little Javascript gem: >> >> ",,," == Array((null,'cool',false,NaN,4)); >> >> => evaluates as true >> >> http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array >> >> I swear, I am never going to complain about Python again. >> > > I am sure you know this, but for the record, Javascript has two equality > operators, '==' and '==='. > > The double form attempts to coerce the left and right sides to the same > type, the triple form does not. > Re "==", this page: http://php.net/manual/en/language.operators.comparison.php states: """If you compare a number with a string or the *comparison involves numerical strings*, then each string is converted to a number and the comparison performed numerically.""" (emphasis added) So they get coerced to numbers if they _look_ like numbers! > '1' == 1 returns true > > '1' === 1 returns false > > The moment I discovered this, I changed all my operators from the double > form to the triple form. Now I no longer have surprises of this nature. >