[Tutor] A range of numbers

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Dec 1 19:38:57 EST 2003



On Mon, 1 Dec 2003, Leung Cris wrote:

> Thx, but while you are at it, can you tell me what is wrong with this code?
>
> >>>while 1:
> >>>     (x,y) = mouse_position()
[code cut]


> Whenever I try it, it says Unpack Sequence (or something like that ).


Hi Leung,


On which line do you get the error message?  Show us the exact error
message, as well as the "traceback".  That'll help us trace back where the
problem is occurring.


I'll assume for the moment that the code breaks on:

    (x,y) = mouse_position()

If so, then we have to double check that mouse_position() always returns a
2-tuple.  According to the docs in,

    http://www.livewires.org.uk/python/pdf/G-graphics.pdf

we may need to call mouse_begin() and mouse_end() between calls to
mouse_position().  It doesn't say what happens if we don't, and I get the
feeling that Bad Things may happen if we don't follow the precepts.


The above advice is only based on a guess though.  *grin* Show us the
error message, and we'll be better equipped to tackle the problem.


Good luck!




More information about the Tutor mailing list