Add vs in-place add of str to list

Mel mwilson at the-wire.com
Thu Oct 2 10:50:29 EDT 2008


rs387 wrote:

> On Oct 2, 8:11 am, Erik Max Francis <m... at alcyone.com> wrote:
>> It's because the `+=` operator is doing the equivalent of calling the
>> `extend` method, which treats its argument as a generic sequence, and
>> doesn't enforce type.
> 
> I see. Do you know whether this is seen as a problem with the language
> design?

No.
  
[1,2,3] + [4,5,6] 

produces 

[1,2,3,4,5,6]

not 

[1,2,3,[4,5,6]]

        Mel.




More information about the Python-list mailing list