subclass of integers

Dan Bishop danb_83 at
Sat Sep 15 01:16:36 CEST 2007

On Sep 14, 9:30 am, Mark Morss <mfmo... at> wrote:
> I would like to construct a class that includes both the integers and
> None.  I desire that if x and y are elements of this class, and both
> are integers, then arithmetic operations between them, such as x+y,
> return the same result as integer addition.  However if either x or y
> is None, these operations return None.

Rather than subclassing int, why not just make a singleton NaN object
with overloaded arithmetic operators that all return NaN?

More information about the Python-list mailing list