[Tutor] Not-so Quick Question
Glen Wheeler
wheelege@tsn.cc
Fri, 27 Apr 2001 01:08:31 +1000
> On Thu, 26 Apr 2001, Glen Wheeler wrote:
>
> > Hey all,
> >
> > I've got this tkinter program which is going to be an arkanoid clone
(eventually). However, it (seemingly) randomly dumps with this error :
> >
> > Traceback (most recent call last):
> > File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball
game.py", line 280, in gogamego
> > co = Screen.coords(block)
> > File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords
> > self.tk.splitlist(
> > ValueError: invalid literal for float(): 27.0expected
>
>
> Hmmm... Do you have any string that looks like "27.0expected"? The
> problem with float() is that if you're going to convert something into a
> float, the whole string needs to have a floatlike quality to it. For
> example:
>
> <snip examples on how to use and what not to do with the int() and float()
functions>
No, I'm not converting anything at all to a float, anywhere in my entire
propgram...well, maybe somehwere but if I am then I'm pretty sure I'm doing
it right.
That leads me to believe that something is spitting inside the function
'coords' in the Canvas widget. I had a poke around, but I am way too newbie
to make any sort of understanding. Why would Tkinter.py output
'27.0expected' for a float instead of '27.0'? Or any number of other flaots
which it may output?
I added a try-except block around that chunk of code, so it looks like
this :
try:
co = Screen.coords(block)
except:
print 'weird float error...'
And on one complete run-through it will print 'weird float error...'
several times, but will continue to hum along nicely regardless. I can't
notice any outside symptoms of this, but I really don't believe in
(essentially) ignoring a problem. Would it be that I am asking for the
co-ordinates of something that is not on the Screen (canvas) ?
Thanks,
Glen.
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>