Can one output something other than 'nan' for not a number values?

Grant Edwards invalid at invalid.invalid
Sat Feb 17 18:52:09 EST 2024


On 2024-02-16, Chris Green <cl at isbd.net> wrote:

> I'm looking for a simple way to make NaN values output as something
> like '-' or even just a space instead of the string 'nan'.

I tried monkey-patching the __format__ method of float, but it's
immutable, so that didnt' work.  Is float.__format__ what's used by
f-strings, the % operator, etc.?

--
Grant


More information about the Python-list mailing list