Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader02.news.zen.co.uk.POSTED!not-for-mail From: Nobody Subject: Re: float("nan") in set or as key Date: Sun, 29 May 2011 22:19:49 +0100 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: <94dkd3F7k4U1@mid.individual.net> <4de1e3e7$0$2195$742ec2ed@news.sonic.net> <4de22007$0$29996$c3e8da3$5496439d@news.astraweb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 17 Organization: Zen Internet NNTP-Posting-Host: 25e14bb8.news.zen.co.uk X-Trace: DXC=h<\c7dVhmMK0`W9@g5D X-Complaints-To: abuse@zen.co.uk Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6578 On Sun, 29 May 2011 10:29:28 +0000, Steven D'Aprano wrote: >> The correct answer to "nan == nan" is to raise an exception, because >> you have asked a question for which the answer is nether True nor False. > > Wrong. That's overstating it. There's a good argument to be made for raising an exception. Bear in mind that an exception is not necessarily an error, just an "exceptional" condition. > The correct answer to "nan == nan" is False, they are not equal. There is no correct answer to "nan == nan". Defining it to be false is just the "least wrong" answer. Arguably, "nan != nan" should also be false, but that would violate the invariant "(x != y) == !(x == y)".