[Python-ideas] Make None a subclass of int [alternative to iNaN]

Ken Hilton kenlhilton at gmail.com
Sun Sep 30 02:05:04 EDT 2018

Hi all,

Reading the iNaN discussion, most of the opposition seems to be that adding
iNaN would add a new special value to integers and therefore add new

I propose, instead, that we make None a subclass of int (or even a certain
value of int) to represent iNaN. Therefore:

    >>> None + 1, None - 1, None * 2, None / 2, None // 2
    (None, None, None, nan, None) # mathematical operations on NaN return
    >>> None & 1, None | 1, None ^ 1
    # I'm not sure about this one. The following could be plausible:
    (0, 1, 1)
    # or this might make more sense, as this *is* NaN we're talking about:
    (None, None, None)
    >>> isinstance(None, int)
    True # the whole point of this idea
    >>> issubclass(type(None), int)
    True # no matter whether None *is* an int or just a subclass, this will
be true as issubclass(int, int) is True

I know this is a crazy idea, but I thought it could have some merit, so why
not throw it out here?

Ken Hilton;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180930/d7aebdcd/attachment.html>

More information about the Python-ideas mailing list