On Mon, Mar 22, 2010 at 7:52 PM, Guido van Rossum <gu...@python.org> wrote:
> On Mon, Mar 22, 2010 at 11:36 AM, Raymond Hettinger
> <raymond.hettin...@gmail.com> wrote:
>> One other thought.
>>
>> The Decimal constructor should now accept floats as a possible input type.
>> Formerly, we separated that out to Decimal.from_float() because
>> decimals weren't interoperable with floats.
>
> Not sure this follows; Fraction(1.1) raises an exception, you have to
> use Fraction.from_float().

Is there any good reason for this, other than a parallel with Decimal?
 It seems to me that Raymond's arguments for allowing direct
construction of a Decimal from a float apply equally well to the
Fraction type.

If we're going to allow Decimal(1.1), I'd like to allow Fraction(1.1)
to succeed as well (giving the equivalent of
Fraction.from_float(1.1)).

The main argument against allowing this (for both Fraction and
Decimal) seems to be that the result of Decimal(1.1) or Fraction(1.1)
could be confusing.  But it's an immediate, explicit confusion, which
can be quickly resolved by pointing the confusee to the section on
floating-point in the appendix, so I don't find this objection
particularly compelling.

Mark
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to