[issue9314] inconsistent result when concatenating list with iterators

2010-07-21 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue9314] inconsistent result when concatenating list with iterators

2010-07-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Jul 21, 2010 at 2:09 AM, Ray.Allen wrote: .. > Does this means "a += b" is not the same as "a = a + b"? For immutable a, the two are practically the same, for mutable, they are necessarily different. This is explained in __iadd__ documentation:

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Ray.Allen
Ray.Allen added the comment: Alexander: > When a is mutable, a += b updates it in-place, so there is no ambiguity: the > type of a cannot change. When you do a + b, there is no reason to treat a as > more deserving than b when selecting the type of the result Does this means "a += b" is not

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Dirkjan Ochtman
Dirkjan Ochtman added the comment: Hmm, I'm still not entirely sure that += shouldn't disallow this as well, just because of the inconsistency. I understand the reasoning now, but it feels like maybe it should be an implementation detail, and it should just be disallowed (refuse to guess). -

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I thought it was common to requalify a bug report into a doc bug. That's upto you and OP. My rule of thumb is if the title reads as either code or doc bug, it's ok to reclassify. If not, it is better to open a separate issue. -- __

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Éric Araujo
Éric Araujo added the comment: Thanks for the explanation of pending, I thought the mysterious Roundup/browser bug had changed the status in my back. Searching for __iadd__ gave me only library/collections; library/stdtypes says very little. I thought it was common to requalify a bug report

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > why the pending status? To me this is a way to say "I will close this next time I look unless someone will change my mind." "pending" has a nice property that it will change to "open" once someone adds a comment. This is exactly what I wanted in thi

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Éric Araujo
Changes by Éric Araujo : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Éric Araujo
Éric Araujo added the comment: Alexander, why the pending status? Dirkjan, do you think this is a doc bug? -- status: pending -> open ___ Python tracker ___

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> belopolsky resolution: -> rejected stage: -> committed/rejected status: open -> pending ___ Python tracker ___ ___

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Dirkjan Ochtman
Dirkjan Ochtman added the comment: Hmm, that's pretty subtle. I guess I understand, at least. -- ___ Python tracker ___ ___ Python-bug

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Note that immutable types are consistent: >>> x = tuple('abc') >>> x += 'def' Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "str") to tuple >>> x + 'def' Traceback (most recent call last): File "",

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- type: -> feature request versions: +Python 3.2 -Python 2.6 ___ Python tracker ___ ___ Python-bugs

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I don't understand is why a += b is different from a + b > in this respect. When a is mutable, a += b updates it in-place, so there is no ambiguity: the type of a cannot change. When you do a + b, there is no reason to treat a as more deserving than

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Dirkjan Ochtman
Dirkjan Ochtman added the comment: Sure, but: >>> a = ['a', 'b', 'c'] >>> a += 'def' >>> a ['a', 'b', 'c', 'd', 'e', 'f'] I think either way is fine (I'm probably on the side of refusing to guess), but what I don't understand is why a += b is different from a + b in this respect. --

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > In other words, if iadd can deal with it, why can't add? Should ['a', 'b', 'c'] + 'def' return ['a, 'b', 'c', 'd' , 'e', 'f'] or 'abcdef'? "In the face of ambiguity, refuse the temptation to guess." -- nosy: +belopolsky _

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: for any *iterable*! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: This actually works for any iterator: >>> l = [] >>> l += 'abc' >>> l ['a', 'b', 'c'] -- nosy: +amaury.forgeotdarc ___ Python tracker ___

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +merwok ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

[issue9314] inconsistent result when concatenating list with iterators

2010-07-20 Thread Dirkjan Ochtman
New submission from Dirkjan Ochtman : This seems wrong: >>> a = [] >>> b = iter(['c', 'd']) >>> a += b >>> c = [] >>> c + iter(['d', 'e']) Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "listiterator") to list In other words, if iadd can deal