Equality check

Dave Angel davea at ieee.org
Wed Aug 3 21:15:56 CEST 2011


On 01/-10/-28163 02:59 PM, Abhishek Jain wrote:
> How to check equality of two nos. in python
>
Python doesn't have numbers, it has various numeric data types.  If all 
you're concerned with are int types, then just use the obvous:

      if  a == b:
             dosomething....

If one or both might be floats, you have to deal with the likelihood 
that one or both may have quantization error, either caused by 
computational approximations, precision limitations, or conversion back 
and forth between string and internal binary representation.

If one is in Decimal, you have to mostly deal with the first two.

If one is complex, ...

DaveA





More information about the Python-list mailing list