Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'garbage': 0.09; 'pm,': 0.10; 'def': 0.12; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'defined': 0.14; 'angelico': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage.': 0.16; 'subject:key': 0.16; 'subject:set': 0.16; 'header:In-Reply-To:1': 0.21; 'fri,': 0.23; 'invalid': 0.25; 'produced': 0.26; 'later': 0.26; 'message- id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'class': 0.29; 'can.': 0.30; "can't": 0.32; "skip:' 10": 0.32; 'steven': 0.32; 'to:addr:python-list': 0.33; 'on,': 0.33; 'chris': 0.34; 'follows:': 0.34; "d'aprano": 0.35; 'else': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'anything': 0.38; 'data': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=8lZ2SmQflVOFdzSOIiviEZ/Rqy6k0Pexc6ciKCxm//4=; b=gGw84G5m8pEHQPX71vbZDQ2RNlZpAuqpaYRSadT64+8HrR+beOeup9BfvyEq5wn+tv PEi8+a/92HmVVU2gmb4po/nmXAQHOACAImXvLzBPNyglRvju6rEPqJQoaTLEC2CGf36U QZl7bMazx90FTZgVNZt7YBOBgrERXeASz1aWE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=pTmmUmGRKxZ+VfATfiXJWmvjQ90qm1gU50+QrlMQIUHB62SiuHP61cFdzMox4WbBMO 0+dLObh/ES+KLfhcdgLfbbZt1rtKNdTSwFTjnr0auzYESpaaWm46E0ozi3ycHYA2B15A a+oaFtiBJ+s/5argm2ss23njXfkdF8+UzO9KI= MIME-Version: 1.0 In-Reply-To: <4de861ae$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <94dkd3F7k4U1@mid.individual.net> <4de1e3e7$0$2195$742ec2ed@news.sonic.net> <4de22007$0$29996$c3e8da3$5496439d@news.astraweb.com> <4de2d746$0$29996$c3e8da3$5496439d@news.astraweb.com> <4de75dd5$0$29983$c3e8da3$5496439d@news.astraweb.com> <94qjvvFb02U1@mid.individual.net> <4de861ae$0$29985$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 3 Jun 2011 14:35:52 +1000 Subject: Re: float("nan") in set or as key From: Chris Angelico To: python-list@python.org 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: 20 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307075755 news.xs4all.nl 49038 [::ffff:82.94.164.166]:40837 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6914 On Fri, Jun 3, 2011 at 2:23 PM, Steven D'Aprano wrote: >> You can't get a valid result from data produced by an invalid >> computation. Garbage in, garbage out. > > Of course you can. Here's a trivial example: > > def f(x): > =A0 =A0return 1 > If your incoming x is garbage, your outgoing 1 is also garbage. Later on, you can use 'isgarbage(x)' to find out whether anything went wrong. You can also use 'isinsane(self)', which is defined as follows: class Programmer: def isinsane(self): return True if float("nan")=3D=3Dfloat("nan") else True Chris Angelico