Bengt Richter bokr at
Sun Jun 1 10:37:02 CEST 2003

On Sun, 1 Jun 2003 09:53:20 +0200 (CEST), Arnd Baecker <arnd.baecker at> wrote:

>I have a question concerning modifying a line created
>within a Canvas:
>It boils down to that (for `plot`  being a Canvas)
>    self.plot.coords(self.line,10,0,10,10,80,100,100,200)
>works, whereas
>    liste=[10,0,10,10,80,100,100,200]
>    self.plot.coords(self.line,liste)
I would try prefixing a '*' on the theory that the function is defined like foo below:
     self.plot.coords(self.line, *liste)

 >>> def foo(first, *rest): print first,rest
 >>> foo(1,2,3,4)
 1 (2, 3, 4)
 >>> r = [2,3,4]
 >>> foo(1,r)
 1 ([2, 3, 4],)
Note what happened in the preceding: the entire r simply became the first and only
arg in the args tuple, which has length 1 instead of 3.

 >>> foo(1,*r)
 1 (2, 3, 4)
Compare this result to the original. We have unpacked r into the arg sequence,
so the r elements show up as if they had been passed as separate args.

>raises the error:
>    TclError: bad screen distance "[10,"
>((Maybe the example below more clearly demonstrates what I mean here.))
>Actually, help(Tkinter.Canvas.coords) gives
>  coords(self, *args) unbound Tkinter.Canvas method
looks like foo above.


If the above works, we can go on to the next problem, which someone else
will have to get into if it's going to happen tonight ;-)

Bengt Richter

More information about the Python-list mailing list