How about adding rational fraction to Python?
Mark Dickinson
dickinsm at gmail.com
Tue Feb 26 22:00:58 EST 2008
On Feb 26, 4:59 pm, Ross Ridge <rri... at caffeine.csclub.uwaterloo.ca>
wrote:
> No, the discussion has been about the behaviour of the division operator
> in Python when used with Python's integral and floating-point data types.
> These data types include many numbers that are not natural numbers.
I'm surprised that no-one has mentioned duck-typing so far in this
discussion. After all, as I understand it the number one reason
for changing / in Python 3.0 is that the 2.x behaviour breaks duck
typing. Consider:
def mean(number_list):
return sum(number_list)/len(number_list)
If you pass a list of floats, complex numbers, Fractions, or Decimal
instances to mean() then it'll work just fine. But if you pass
a list of ints or longs, it'll silently return the wrong result.
True division and floor division are different operations. It doesn't
seem ridiculous to use different operators for them.
Mark
More information about the Python-list
mailing list