[ python-Bugs-848812 ] Inconsistent list.__add__/__addi__.

SourceForge.net noreply at sourceforge.net
Mon Dec 1 05:38:32 EST 2003


Bugs item #848812, was opened at 2003-11-25 04:50
Message generated for change (Comment added) made by jemfinch
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=848812&group_id=5470

Category: None
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Nobody/Anonymous (nobody)
Summary: Inconsistent list.__add__/__addi__.

Initial Comment:
>>> L = [1,2,3] 
>>> L + (1,2,3) 
Traceback (most recent call last): 
  File "<stdin>", line 1, in ? 
TypeError: can only concatenate list (not "tuple") to list 
>>> L += (1,2,3) 
>>> L 
[1, 2, 3, 1, 2, 3] 
 
I've always been somewhat annoyed that list.__add__ 
didn't accept any iterable (just lists), but to have += accept 
any iterable but not + is just plain inconsistent. 

----------------------------------------------------------------------

>Comment By: Jeremy Fincher (jemfinch)
Date: 2003-12-01 05:38

Message:
Logged In: YES 
user_id=99508

Neither google nor the CVS log for Objects/listobject.c turned up 
any past discussion or pronouncement on this. 
 
Which behavior is more desirable may not be up for debate, but 
it's still highly inconsistent to have += work in places where + 
does not. 

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-11-29 03:44

Message:
Logged In: YES 
user_id=80475

It's a feature, not a bug.  The goal is to eliminate
unattractive, error prone constructions.  Probe the archives
for past discussion and pronouncement on this.  

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=848812&group_id=5470



More information about the Python-bugs-list mailing list