Proposal: === and !=== operators

Chris Angelico rosuav at
Sun Jul 13 01:15:56 CEST 2014

On Sun, Jul 13, 2014 at 9:06 AM, Roy Smith <roy at> wrote:
> But, you can still have:
>>>> print x
> 1.0
>>>> print y
> 1.0
>>>> print x == y
> False
> which, I know, isn't really what you were talking about, but it is part
> of the general confusion of using floats.

This is partly because of the oh-so-handy magic of Python's float
reprs, rounding them off. Can you do the same trick in Python 3, where
the repr rules changed? If so, I would say this is a potential flaw in
the display, although not really a serious one.

But in terms of the OP's complaint, this is still fine, as the state
must have changed for it to be unequal. If you care about equality
differences and NOT about the above change, well, I think I've found
your solution: instead of "x == y", you should use "repr(x) ==
repr(y)" :)


More information about the Python-list mailing list