TypeError: unsubscriptable object

Weil weil at sireconnect.de
Thu Jun 8 15:09:53 EDT 2000


Cyrille Artho <cartho at mordor.ch> schrieb in im Newsbeitrag:
393F488B.37F13682 at mordor.ch...
> > What's possible (but it's not possible to determine this from your
snippets)
> > is that you accidentally assign something else to W elsewhere.
> self.W is equal to
> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
> just before the assignment.
> self.W[i][j] = self.W[i][j]  + ...
> I attached the entire script to this post (it's not too big).
> --
> Regards,
> Cyrille Artho - http://artho.com/ - Tel. +41 - [0]1 - 313 08 92
> Alcohol is the anesthesia by which we endure the operation of life.
>                 -- George Bernard Shaw

Well, I think it's not W that is unsubscriptable, but P.
First you do this:
>         P = copy.deepcopy(I)
Later this:
>         P = 1 / (1 + math.exp(-sum))
which makes P unsubscriptable here:
>                 self.W[i][j] = self.W[i][j]  + n * (
>                     r(S[i] - P[i]) - alpha * (1 - r)
>                     * (S[i] - (1 - P[i]))) * I[j]
but pretty usable here:
>             self.V[i] = self.V[i] + n * (
>                 r(O - P) - alpha * (1 - r) * (O - (1 - P))) * S[i]

...and by the way, r(S[i] - P[i]) won't work either,
maybe you mean: r *(S[i] - P[i]).















More information about the Python-list mailing list