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

Chris Angelico rosuav at gmail.com
Sun Feb 18 14:50:21 EST 2024


On Mon, 19 Feb 2024 at 06:47, Grant Edwards via Python-list
<python-list at python.org> wrote:
> I would be tempted to try monkey-patching the float class to override
> the __format__ method. I have no idea what side effects that might
> have, or if it's even used by the various formatting mechanisms, so
> you might end up scraping bits off the walls...
>

You can try, but you'd have to do it in C - the float type is
immutable in Python.

ChrisA


More information about the Python-list mailing list