Can anyone spot my float error?
Alex Martelli
aleaxit at yahoo.com
Fri Sep 1 17:30:30 EDT 2000
"Richard Harvey" <tririch at connect.net> wrote in message
news:IZSr5.8460$Jq2.15065 at dfw-read.news.verio.net...
> I'm seeing an extrememly wacky effect in 1.5.2, and the code is so simple
> I'm baffled that I cannot see the error. Here is a snippet:
>
> timer = 0.0
>
> def testFunc():
> global timer
> timer = timer + 0.5
> if timer > 10.0:
> print "timer > 10"
>
> If I repeatedly call testFunc in a loop, my print statement never gets
> called. However, if I change the code to the following everything works
I can't reproduce your problem. Saving this code in Script1.py,
importing it, and running:
>>> for i in range(23):
... Script1.testFunc()
...
I obtain the output:
timer > 10
timer > 10
timer > 10
>>>
just as expected. What's your Python build...?
Alex
More information about the Python-list
mailing list