[Tutor] Is IDLE prone to memory losses ?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 12 Dec 2001 00:15:43 -0800 (PST)

On Wed, 12 Dec 2001, Jean Montambeault wrote:

> OK. If I run this I get the error message following:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> #! /usr/bin/env python
> from Tkinter import *
> def move():
>     "d=E9placement de la balle"
>     global x1, y1, dx, dy, flag
>     x1, y1=3D x1 + dx, y1 + dy
>     for c in range[1,6]:

There is something very suspicious about this line: I just tried this in
the interpreter, and:

>>> for c in range[1, 6]:
=2E..     print c
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsubscriptable object

And this fits closely with the TypeError message that you were getting:

> TypeError: unsubscriptable object

I believe you meant to call the range() function instead:

>>> for c in range(1, 6):
=2E..     print c

Be aware, though, that range(1, 6) goes from 1 to 6, but not including 6.

However, I don't know if this is the whole story, since your error message
still looked very strange to me.  Hmmm... Try to fix the subscripting
problem above, and see if that clears things up for you.

Best of wishes to you.