On 9/29/2012 11:48 PM, Steven D'Aprano wrote: > On 30/09/12 10:43, Jan Kaliszewski wrote: >> Hello, >> >> In http://docs.python.org/release/3.2.3/reference/expressions.html#in we >> read: "[...] This can create the illusion of non-transitivity between >> supported cross-type comparisons and unsupported comparisons. For >> example, >> Decimal(2) == 2 and 2 == float(2) but Decimal(2) != float(2)." > [...] >> Is it a bug in the docs or in Python itself? (I checked that in 3.2, >> but it may be true for 3.3 as well) > > Documentation bug. It used to be the case that Decimal and float did not > compare equal: Questions about past releases are better directed to python-list (where Steven would have given same answer ;-). But anyway, please open a doc issue on the tracker to update that item. > steve at runes:~$ python3.1 > Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > py> from decimal import Decimal > py> Decimal(2) == 2.0 > False > > but starting in 3.2 they do. But of course there are traps for the unwary, > due to binary floats, e.g. Decimal("0.1") != 0.1 > > > -- Terry Jan Reedy
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