On 2005-04-24, Michael Sparks <[EMAIL PROTECTED]> wrote:

>>>> a=["hello"]
>>>> a = a + "world"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: can only concatenate list (not "str") to list

> However if we do this just slightly differently:
>
>>>> a = ["hello"]
>>>> a += "world"
>>>> a
> ['hello', 'w', 'o', 'r', 'l', 'd']
>
> We get completely different behaviour. This strikes me as a bug - should I
> log it as one, or is there a good reason for this behaviour?

I think it's a bug regardless of the reason for the behavior: 

 1) It doesn't do what a reasonable user expects.

 2) It doesn't do what the documentation says it will.
    According to the language reference,

      An augmented assignment expression like x += 1 can be
      rewritten as x = x + 1 to achieve a similar, but not
      exactly equal effect. In the augmented version, x is only
      evaluated once.

    I don't consider the two results you posted "similar".
  
-- 
Grant Edwards                   grante             Yow!  TAILFINS!!...click...
                                  at               
                               visi.com            
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to