loop help

Gorlon the Impossible meatpodeye at yahoo.com
Thu Oct 27 03:00:34 EDT 2005


Hello. I am using Python 2.3.5 with IDLE 1.0.5 on a Windows98 PC.
I have some programming experience but mostly I am still learning.
I am having some trouble understanding the behaviour of a piece of
code I have written. It plots points using PIL.
Here is my loop:

triangle = [(320,27),(172,323),(468,323)]
currentpoint = (randint(0,640),randint(0,350))
t = 0
while t < 10:
    ct = choice(triangle)
    mp = (currentpoint[0] + ct[0])/2, (currentpoint[1] + ct[1])/2
    draw.point(mp,(0,0,0))
    currentpoint = mp
    t = t + 1

This works fine. But, if I try to divide by a floating point number in
the calculation of mp, instead of mp being overwritten each time thru
the loop, it starts accumulating, leading to overflow errors for large
values of t.
Why is this?



More information about the Python-list mailing list