list in a tuple
Wildemar Wildenburger
lasses_weil at klapptsowieso.net
Thu Dec 27 14:20:01 EST 2007
Subject: Re: list in a tuple
To:
Cc:
Bcc:
Reply-To:
Newsgroup: comp.lang.python
-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-
montyphyton at gmail.com wrote:
> After some tought I must agree that this is a wart more than
> a bug and that it will probably be best not to mess with it.
> However, what do you guys think about the print wart in Py3k
> described at
http://filoxus.blogspot.com/2007/12/python-3000-how-mutable-is-immutable.html#links
> (im not trying to advertise my blog, I just don't feel like
> typing the whole problem all over again)?
>
From that post:
> Ok, I do admit that doing
>
> a = ([1], 2)
> a[0].append(2)
>
> also doesn't throw an error, but this only confuses me more.
>
Why? You mutate the list, but the tuple does not change. It is still a
tuple of a list and an int. At least that's how I think about it, and I
seem to recall reading that beavior justified like this (don't ask me
where though (might have been "Dive Into Python", but maybe not)).
/W
More information about the Python-list
mailing list