How about adding rational fraction to Python?

J. Cliff Dyer jcd at sdf.lonestar.org
Tue Feb 26 14:16:20 EST 2008


On Tue, 2008-02-26 at 13:51 -0500, D'Arcy J.M. Cain wrote:
> On Tue, 26 Feb 2008 13:39:38 -0500
> "J. Cliff Dyer" <jcd at sdf.lonestar.org> wrote:
> > >>> a = 20000 * 20000
> > >>> b = 200000 * 200000
> > >>> type(a)
> > <type 'int'>
> > >>> type(b)
> > <type 'long'>
> 
> A long int is still integral which is the crux of the issue.
> 

So do you believe that you should not be able to do natural division
without explicitly casting ints as floats, or is your concern just that
you want to still be able to to integer division simply?

For me personally, I'm happy knowing that integer division is still
available through the // operator.  I'm not offended that other, highly
useful forms of division would be given operator status.  Granted, I'm
not old school like you, but I do appreciate clean design, and typing:

float(3)/4 always struck me as an ugly hack to get integers to do
something that comes naturally to them--divide into a result outside the
set of integral numbers.

I agree that integer division is useful and important, but I don't think
it's a travesty to support other kinds of division, especially when
integer division still has its own operator.

Cheers,
Cliff





More information about the Python-list mailing list