In <c37a3b9c-6fe8-48aa-b703-9b4f922c3...@googlegroups.com> Miki Tebeka 
<miki.teb...@gmail.com> writes:

> >> I'm trying to find a way to have json emit float('NaN') as 'N/A'.
> > No.  There is no way to represent NaN in JSON.  It's simply not part of the
> > specification.
> I know that. I'm trying to emit the *string* 'N/A' for every NaN.

import math

x = possibly_NaN()

if math.isnan(x):
    x = 'N/A'

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to