TypeError: unsubscriptable object
Cyrille Artho
cartho at mordor.ch
Wed Jun 7 18:42:11 EDT 2000
Hi,
I am learning Python and liked it quite a lot so far, and I am now
implementing a small neural network simular in it. The graphical part in
Tkinter is now done, but I ran into the following error:
$ python nn.py
Traceback (innermost last):
File "nn.py", line 81, in ?
n.playRound()
File "nn.py", line 73, in playRound
self.W[i][j] = self.W[i][j] + n * (
TypeError: unsubscriptable object
Line 74 continues the formula, which should be correct (at least
syntactically).
The initialization of the object where W is a member goes like this:
def __init__(self):
self.V = [0, 0, 0]
self.W = [[0,0,0], [0,0,0], [0,0,0]]
self.W is defined (it works if I print its value just one line before
the error occurs), but I cannot change it. How should I change that
array? I tried it with simpler examples, where it worked (W was also a
member of an object, where I accessed it later - no problems). Why
doesn't it work now? I can send someone the entire script I have written
so far if it helps. Help would be greatly appreciated!
--
Regards,
Cyrille Artho - http://artho.com/ - Tel. +41 - [0]1 - 313 08 92
Better once than never, for never too late.
-- Shakespeare, "The Taming of the Shrew"
More information about the Python-list
mailing list