Appending a list's elements to another list using a list comprehension

Robert Kern robert.kern at gmail.com
Wed Oct 17 20:27:08 EDT 2007


Debajit Adhikary wrote:
> On Oct 17, 5:40 pm, Paul Hankin <paul.han... at gmail.com> wrote:
>> To answer your question though: a += b is *not* the same as a = a + b.
>> The latter would create a new list and assign it to a, whereas a += b
>> updates a in-place.
> 
> I know I'm being a little finicky here, but how would someone know
> that a+=b is not the same as a=a+b?
> Any documentation or reference that mentions this?

http://docs.python.org/ref/augassign.html

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list