Fwd: Using fractions instead of floats

Andres Riofrio andres.j.new at gmail.com
Mon Oct 1 05:10:05 CEST 2007


PS: Sorry, George Sakkis, for the double emailing... I forgot to add
python-list in the To: field the first time. :)

Haha. Ok. Thank you for pointing me to those links :). I hadn't
thought of searching for the word 'rational' instead of 'decimal'...

>From what I've read, seems that the principal reason for rejecting the
PEP is that there was not much need (enthusiasm)... Well, then I have
a question: Is there a way to make 5/2 return something other than an
integer? I can do:
class int(int):
  def __add__(self, other):
    pass
but that will only work if I do int(5)/int(2)...

(setting __builtin__.int=int doesn't work, either)

What I'd like is to be able to implement what I put in the proposal,
as I don't think it's a really big language change...

On 9/30/07, George Sakkis <george.sakkis at gmail.com> wrote:
> On Sep 30, 9:35 pm, andresj <andres.j.... at gmail.com> wrote:
> > I was doing some programming in Python, and the idea came to my mind: using fractions instead of floats when doing 2/5.
> > (...)
> > I would like to get some feedback on this idea. Has this been posted
> > before? If so, was it rejected? and for what?
>
> Is internet down today ?
>
> http://pypi.python.org/pypi/clnum/1.2
> http://www.python.org/dev/peps/pep-0239/



More information about the Python-list mailing list