Newbie : this works in one direction but get the error on the return path
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed Feb 25 10:51:18 EST 2009
En Wed, 25 Feb 2009 13:31:25 -0200, Gary Wood <pythonsky at sky.com> escribió:
Start looking at the error:
> Traceback (most recent call last):
> File "E:/python/handson/backAndForth4.py", line 97, in <module>
> main()
> File "E:/python/handson/backAndForth4.py", line 90, in main
> moveAllOnLine(faceList, -dx, dy, stepsAcross/2, wait)
> File "E:/python/handson/backAndForth4.py", line 21, in moveAllOnLine
> for i in range(repetitions):
> TypeError: 'float' object cannot be interpreted as an integer
It's rather understandable - you have a float object where Python is
expecting an integer.
Where? The traceback says it all:
> File "E:/python/handson/backAndForth4.py", line 21, in moveAllOnLine
> for i in range(repetitions):
Ok, so repetitions should be an integer, but it isn't. Where does it come
from? It's an argument to moveAllOnLine, and was called from main (see the
line above that in the traceback). Now we look near that line:
> for i in range(2):
> moveAllOnLine(faceList, dx, 0, stepsAcross, wait)
> moveAllOnLine(faceList, -dx, dy, stepsAcross/2, wait)
> moveAllOnLine(faceList, -dx, -dy, stepsAcross//2, wait)
Don't you see something suspicious...?
--
Gabriel Genellina
More information about the Python-list
mailing list