syntax glitch with +=

Steve Holden sholden at holdenweb.com
Fri Feb 21 08:09:56 EST 2003


"David Eppstein" <eppstein at ics.uci.edu> wrote in message
news:eppstein-4EAA27.18054820022003 at news.service.uci.edu...
> In article <mailman.1045784817.1817.python-list at python.org>,
>  "Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote:
>
> > No. += *uses* extend, but they are not identical. Specifically, every
> > augmented *assignment* operator includes an assignment as part of the
> > operation.
> >
> > In the case of a list, the assignment is redundant, but still occurs.
>
> Ok, thanks for the explanation.  The error with += makes more sense in
> that case, since a (redundant) assignment is happening.  I guess this
> means that, after the assignment, the variable name will be in local
> scope?
>

Since locality of scope is determined by static source analysis, "L" is
decreed local as a result of its appearance on the LHS of an assigment. It's
therefore local throughout the second function. Hence the error message you
observed.

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Register for PyCon now!            http://www.python.org/pycon/reg.html







More information about the Python-list mailing list