Fwd: Using fractions instead of floats

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Oct 1 08:04:07 CEST 2007

En Mon, 01 Oct 2007 00:10:05 -0300, Andres Riofrio  
<andres.j.new at gmail.com> escribi�:

> 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)...

I'm afraid not. But if you are crazy enough you can preprocess your source  
using something similar to the tokenize example  

Gabriel Genellina

More information about the Python-list mailing list