[Tutor] Is IDLE prone to memory losses ?

Gregor Lingl glingl@aon.at
Wed, 12 Dec 2001 09:46:53 +0100

----- Original Message -----
From: "Danny Yoo" <dyoo@hkn.eecs.berkeley.edu>
To: "Jean Montambeault" <jrm@videotron.ca>
Cc: <tutor@python.org>
Sent: Wednesday, December 12, 2001 9:15 AM
Subject: Re: [Tutor] Is IDLE prone to memory losses ?

On Wed, 12 Dec 2001, Jean Montambeault wrote:

> OK. If I run this I get the error message following:
> ====================================
> #! /usr/bin/env python
> from Tkinter import *
> def move():
>     "déplacement de la balle"
>     global x1, y1, dx, dy, flag
>     x1, y1= 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]:
...     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

.... 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.

I think this is the whole story. The error-message means - in my opinion -
that range is not a subscriptable object:

>>> type(range)
<type 'builtin_function_or_method'>

subscription means getting acces to an element of some compund data object
via an index,
as is possible for strings, lists etc. This is of course not possible for a
built-in functin as range()
(but this is what you tried by range[])

See also: http://www.python.org/doc/current/ref/assignment.html

hope that "clears things up"