Tuples and immutability

Eric Jacoboni eric.jacoboni at gmail.com
Sun Mar 2 09:17:11 EST 2014


Le 02/03/2014 15:05, Mark Lawrence a écrit :

> The behaviour is consistent except when you try to modify a tuple.
> 

Not in my opinion...

li = [10, 30]
li = li + "spam"   --> TypeError: can only concatenate list (not "str")
li += "spam"       --> Ok

So, not, that's not what i call consistent.

And it's not related to tuples...

> I'd like to see you get update to work on a list.  This shows how
> confused you are over this issue.

Well, sorry, i wanted to write .append()





More information about the Python-list mailing list