Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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; 'that?': 0.05; 'override': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'wrapper': 0.09; 'python': 0.11; '2.7': 0.14; '"n/a"': 0.16; 'emits': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nan': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'bit': 0.19; 'thu,': 0.19; 'please?': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'patch': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'received:209.85.220.174': 0.31; "i'd": 0.34; 'could': 0.34; 'received:209.85': 0.35; 'possible.': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:j 20': 0.36; 'that!': 0.36; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'first': 0.61; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=ImP6hfxj175OZ7TAOMEIdgd0uUEnqJvDjNot7Hf1iM4=; b=YZpgutbuMc1Zo+paEnhtJn6SdGDkzFcpiasDTsZyawb6QLZXg0zI3mNujSCI3kawbg Qj/RIJdv22Zc+utBLkiGkgcJtyIUePUindmd4i47eQyPSJoTMl01CyFC072iBB5Vjei8 rAHCnBfk47Br9iK9V5N4C6ENZeLwGwt38zMyy2KgXHUuGYz/nhzf7pP9LHoXlmso8y11 zqBgtdRMCJMvNqNHQbu1Z4uL5FUwPhrGZdChPxFIfVEpf7qhJtXWtxKHwKc/v60F5FOc hZsDiFtEO1E9Yn8F/GALvqALkYpa/2nVG9F9aPWmjL8z3gVltJ+aP1sIC8lE1AsZsjQq Pqxg== MIME-Version: 1.0 X-Received: by 10.52.37.109 with SMTP id x13mr5898066vdj.10.1366249597473; Wed, 17 Apr 2013 18:46:37 -0700 (PDT) In-Reply-To: <20130418013938.GB28906@localhost> References: <20130417224030.GA28906@localhost> <1040891b-d350-4304-8112-de4a383562dc@googlegroups.com> <20130418013938.GB28906@localhost> Date: Thu, 18 Apr 2013 11:46:37 +1000 Subject: Re: Encoding NaN in JSON From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366249600 news.xs4all.nl 2176 [2001:888:2000:d::a6]:35589 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43797 On Thu, Apr 18, 2013 at 11:39 AM, Roland Koebler wrote: > as a quickhack, you > could even monkey patch json.encoder.floatstr with a wrapper which > returns "N/A" for NaN. (I've tested it: It works.) Wait... you can do that? It's internal to iterencode, at least in Python 3.3 and 2.7 that I'm looking at here. Can you share your code please? I'd like to try that! When I first looked at the docstring, I was thinking "Ah, can I override the bit that emits NaN to return \"N/A\" instead?", but the code made me think that's not possible. ChrisA