Short-circuit Logic
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue May 28 09:51:37 EDT 2013
On Tue, 28 May 2013 01:39:09 -0700, Ahmed Abdulshafy wrote:
> He just said that the way to test for zero equality is x == 0, and I
> meant that this is true for integers but not necessarily for floats. And
> that's not specific to Python.
Can you show me a value of x where x == 0.0 returns False, but x actually
isn't zero?
Built-in floats only, if you subclass you can do anything you like:
class Cheating(float):
def __eq__(self, other):
return False
--
Steven
More information about the Python-list
mailing list