"Dan Bishop" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Mike Meyer wrote:This version includes the input from various and sundry people.Thanks...to everyone who contributed.
<mike
PEP: XXX Title: A rational number module for PythonImplicit Construction ---------------------
When combined with a floating type - either complex or float - or a decimal type, the result will be a TypeError. The reason for this is that floating point numbers - including complex - and decimals are already imprecise. To convert them to rational would give an incorrect impression that the results of the operation are precise. The proper way to add a rational to one of these types is to convert the rational to that type explicitly before doing the operation.
I disagree with raising a TypeError here. If, in mixed-type expressions, we treat ints as a special case of rationals, it's inconsistent for rationals to raise TypeErrors in situations where int doesn't.
2.52 + 0.5TypeError: unsupported operand types for +: 'Rational' and 'float'Rational(2) + 0.5
I agree that the direction of coercion should be toward the floating type, but Decimal doesn't combine with Float either. It should be both or neither.
John Roth
John Roth
-- http://mail.python.org/mailman/listinfo/python-list