Does python suck or I am just stupid?

Peter Hansen peter at engcorp.com
Sat Feb 22 13:04:21 EST 2003


(Short answer: Python doesn't suck. ;-)

Andy Mroczkowski wrote:
> I've been tearing my hair out over a bug(?) I've come across.  
> u = 0.0
> u_inc = 0.001
> 
> v = (0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1.0, 1.0, 1.0)
> 
> while u <= 1.0:
>         for x in v:
>                 if u == x:
>                         print u, x
>         u = u + u_inc
[...]
> What is wrong?  Is this some weird feature?  Or is Python broken?  And
> sorry if this is something silly that I'm overlooking on my part.

Please see http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp

(Then change the u==x comparison from a strict equality check, as
prescribed therein.)

-Peter




More information about the Python-list mailing list