Short-circuit Logic

Grant Edwards invalid at invalid.invalid
Tue May 28 11:14:03 EDT 2013


On 2013-05-28, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> 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?

I'm confused.  Don't all non-zero values satisfy your conditions?

>>> x = 1.0
>>> x == 0.0
False
>>> x is 0.0
False



-- 
Grant Edwards               grant.b.edwards        Yow! I'm dressing up in
                                  at               an ill-fitting IVY-LEAGUE
                              gmail.com            SUIT!!  Too late...



More information about the Python-list mailing list