f---ing typechecking

Farshid Lashkari no at spam.com
Wed Feb 14 16:44:16 EST 2007


Szabolcs Nagy wrote:
>>>> L=[1]
>>>> L.extend((1,))
>>>> L
> [1, 1]

Are list.extend() and list concatenation supposed to behave differently? 
I always thought concatenation was just shorthand for calling extend().

However the following seems to work:

 >>> L = [1]
 >>> L += (2,)
 >>> L
     [1, 2]

It seems like the '+' operator for lists should accept any iterable for 
the right side argument to be consistent with extend() and the '+=' 
operator.

-Farshid



More information about the Python-list mailing list