On Numbers

Dan Bishop danb_83 at yahoo.com
Mon Jan 16 00:14:33 EST 2006


Alex Martelli wrote:
> Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>
> > Mike Meyer <mwm at mired.org> writes:
> > > I'd like to work on that. The idea would be that all the numeric types
> > > are representations of reals with different properties that make them
> > > appropriate for different uses.
> >
> > 2+3j?
>
> Good point, so s/reals/complex numbers/ -- except for this "detail",
> Mike's idea do seem well founded.
>
> What *I* would also like would be a basenumber abstract class, like the
> existing basestring, such that alternate numerics (like those I supply
> in gmpy) could inherit from it in order to assert "yes, I *AM* a
> number!" and allow isinstance-based checks rather than ones based on
> "try to sum 0 and see if that gives an exception".  A very small,
> localized, and potentially useful change, IMHO.

+1

although I personally would prefer

       (number)
       /       \
(realnumber)   complex
  |   |   |
int float |
          |
        Decimal




More information about the Python-list mailing list