On Mon, Mar 22, 2010 at 7:52 PM, Guido van Rossum <guido at python.org> wrote: > On Mon, Mar 22, 2010 at 11:36 AM, Raymond Hettinger > <raymond.hettinger at 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4