Python wierdness

Sam Schulenburg samschul at pacbell.net
Wed Feb 7 23:42:45 CET 2001


This advice also applies to other languages.
Sam Schulenburg

> > What's going on here, and how could one get around it?
>
> unless you know exactly what you're doing, don't use "=="
> on floating point values.  alternatives:
>
>     if abs(a - b) < some_small_value:
>         ...
>
> or even
>
>     if str(a) == str(b):
>         ...
>
> Cheers /F
>
>


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list