off topic but please forgive me me and answer

Dave Angel davea at ieee.org
Sat Apr 3 00:11:32 CEST 2010



Mensanator wrote:
> On Apr 1, 9:44 pm, Steven D'Aprano <st... at REMOVE-THIS-
> cybersource.com.au> wrote:
>   
>> <snip>
>>>>> 1/2.0
>>>>>           
>> 0.25
>>
>> If you want an exact result when multiplying arbitrary fractions, you
>> need to avoid floats and decimals and use Fractions:
>>
>>     
>>>>> Fraction(1, 2)**2
>>>>>           
>> Fraction(1, 4)
>>     
>
> Where do you get that from?
>
>   
In Python2.6,

from fractions import Fraction

And Fraction is now a class which supports fractional arithmetic.




More information about the Python-list mailing list