[Tutor] Not-so Quick Question
Glen Wheeler
wheelege@tsn.cc
Fri, 27 Apr 2001 01:45:46 +1000
> On 0, Glen Wheeler <wheelege@tsn.cc> wrote:
> > > 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...
>
> The actual float() happened in line 1929 of Tkinter.py, in a function that
> was in turn called by your program.
>
> Does the string "expected" occur in any part of your program? Or the
input?
>
Nope, never...not unless your counting docstrings :)
> > 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'?
>
> Hmm. In Tcl, everything is a string. Accidentally added 27.0 and
"expected"
> together for some reason?
>
Quite possible...but I have no idea how that would happen. Unless threads
are messing around.
> > 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) ?
>
> Try to make your problem as small as possible, ie make the smallest
program
> that still has the problem. This may well be a Tcl/Tk bug, if you're sure
> the 'expected' string doesn't occur in your program.
>
I'll try and replicate it in a small prog asap. Could threads be
confusing tcl? I have one running which almost never stops and spawns other
threads (but only two are ever running at the same time). I read somewhere
that variable values can get confused by threads - is this an issue here?
I'm running win98.
> --
> Remco Gerlich
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>