For variables outside loop causes exception
David Goodger
goodger at python.org
Fri Oct 17 10:26:43 EDT 2003
Gordon Williams wrote:
> for i, obsData in enumerate(epochData):
> Pcor[i] = obsData[3]
> Xs[i] = obsData[4]
>
> Asub, Lsub= Solve_all.model_matrix(Xs[:i+1], Pcor[:i+1],Xr)
>
> The exception is:
>
> Asub, Lsub= Solve_all.model_matrix(Xs[:i+1], Pcor[:i+1],Xr)
> UnboundLocalError: local variable 'i' referenced before assignment
Could epochData be empty? If so, i and obsData will not be
declared for that call. Local variables are not kept between
function calls.
-- David Goodger
More information about the Python-list
mailing list