syntax glitch with +=

Jp Calderone exarkun at intarweb.us
Thu Feb 20 21:20:08 EST 2003


On Thu, Feb 20, 2003 at 06:05:48PM -0800, David Eppstein wrote:
> 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?

  Not if you use a global declaration (or if you don't, since an exception
is raised and the assignment never occurs ;)

  Jp

-- 
        "I quite agree with you," said the Duchess; "and the moral of
that is -- Be what you would seem to be' -- or, if you'd like it put
more simply -- Never imagine yourself not to be otherwise than what it
might appear to others that what you were or might have been was not 
otherwise than what you had been would have appeared to them to be
otherwise.'"       -- Lewis Carrol, "Alice in Wonderland"
-- 
 up 12 days, 6:28, 5 users, load average: 0.25, 0.32, 0.38
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030220/3982e094/attachment.sig>


More information about the Python-list mailing list