Augmented Assignement (was: Re: PEP scepticism)

Mark 'Kamikaze' Hughes kamikaze at kuoi.asui.uidaho.edu
Fri Jun 29 13:45:54 EDT 2001


28 Jun 2001 11:32:34 -0700 in <mailman.993753043.27848.python-list at python.org>,
Paul Prescod <paulp at ActiveState.com> spake:
> I think Python has been getting better and better as time goes on. But I
> do have a concern about augmented assignment. How can a newbie
> understand that tuples are "immutable" if this works:
> mytuple += (foo,bar)

  What would you expect from "mytuple = mytuple + (foo,bar)", and why
would this be different from "mytuple += (foo,bar)"?

> Worse, once they've learned that this does NOT affect other references
> to mytuple they are bound to be confused by
> mylist += [foo, bar]
> which does!

  What would you expect from "mylist = mylist + [foo, bar]", and why
would this be different from "mylist += [foo, bar]"?

> I've seen this confusion already -- in a draft of a book no less.

  I'm confused by your confusion.  However, it looks like that author
should probably make this more clear.

-- 
 <a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"I will tell you things that will make you laugh and uncomfortable and really
fucking angry and that no one else is telling you.  What I won't do is bullshit
you.  I'm here for the same thing you are.  The Truth." -Transmetropolitan #39



More information about the Python-list mailing list