list in a tuple

montyphyton at gmail.com montyphyton at gmail.com
Mon Dec 24 10:22:02 EST 2007


Recently, I got into a debate on programming.reddit.com about
what should happen in the following case:

>>> a = ([1], 2)
>>> a[0] += [3]

Currently, Python raises an error *and* changes the first element of
the tuple. Now, this seems like something one would want to
change - why raise an error *and* execute the thing it
was complaining about? The discussion seems to have no end, and
that is why I'm posting here. I would like to know what is the opinion
of the people on this group... Am I really mistaking for thinking that
this is strange and unwanted behavior? Btw I understand *why* is this
happening, I just think it should change...
And here is the post that started this discussion:
http://filoxus.blogspot.com/2007/12/python-3000-how-mutable-is-immutable.html#links

Thanks for your replies



More information about the Python-list mailing list