[Python-Dev] == on object tests identity in 3.x
Antoine Pitrou
antoine at python.org
Wed Jul 9 15:21:26 CEST 2014
More information about the Python-Dev mailing list
Wed Jul 9 15:21:26 CEST 2014
- Previous message: [Python-Dev] == on object tests identity in 3.x
- Next message: [Python-Dev] == on object tests identity in 3.x
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le 09/07/2014 00:21, Stephen J. Turnbull a écrit : > Steven D'Aprano writes: > > > I don't think so. Floating point == represents *numeric* equality, > > There is no such thing as floating point == in Python. You can apply > == to two floating point numbers, but == (at the language level) > handles any two numbers, as well as pairs of things that aren't > numbers in the Python language. This is becoming pointless hair-splitting. >>> float.__eq__(1.0, 2.0) False >>> float.__eq__(1.0, 2) False >>> float.__eq__(1.0, 1.0+0J) NotImplemented >>> float.__eq__(1, 2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor '__eq__' requires a 'float' object but received a 'int' Please direct any further discussion of this to python-ideas.
- Previous message: [Python-Dev] == on object tests identity in 3.x
- Next message: [Python-Dev] == on object tests identity in 3.x
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list