Namespacedifference reading - writing ??
fredrik at pythonware.com
Fri Jun 27 15:13:16 CEST 2003
Peter Abel wrote:
> >>> outer()
> x in inner =Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File "<interactive input>", line 7, in outer
> File "<interactive input>", line 4, in inner
> UnboundLocalError: local variable 'x' referenced before assignment
> Is there really a difference in namespacehandling depending
> on writing or reading variables?
you cannot assign to variables in an outer scope (except for the global
scope, in case you have to mark the variable as global).
the details are in the language reference:
More information about the Python-list