A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-March/098548.html below:

[Python-Dev] Decimal & lt; -& gt; float comparisons in py3k.

[Python-Dev] Decimal & lt; -& gt; float comparisons in py3k.Raymond Hettinger raymond.hettinger at gmail.com
Fri Mar 19 17:38:27 CET 2010
On Mar 19, 2010, at 4:50 AM, Antoine Pitrou wrote:

> Glenn Linderman <glenn <at> nevcal.com> writes:
>> 
>> On the other hand, if the default behavior is to do an implicit 
>> conversion, I don't know of any way that that could be turned into an 
>> exception for those coders that don't want or don't like the particular 
>> type of implicit conversion chosen.
> 
> You still haven't given a good reason why we should raise an exception rather
> than do a comparison, though.
> 
> The fact that some particular coders don't like "the particular type of implicit
> conversion chosen" is a particularly weak argument. Python isn't a language
> construction framework; we try to choose useful defaults rather than simply give
> out a box of tools. If some people don't like the defaults (significant
> indentation, limitless precision integers, etc.), there are other choices out 
> there.


The reason to prefer an exception is that decimal/float comparisons
are more likely to be a programmer error than an intended behavior.
Real use cases for decimal/float comparisons are rare and would
be more clearly expressed with an explicit conversion using Decimal.from_float().

Of course there is a precedent, I can compare "120" < 140 in AWK
and get an automatic implicit conversion ;-)  

Just because we can compare, doesn't mean we should.


Raymond
More information about the Python-Dev mailing list

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