list in a tuple

montyphyton at gmail.com montyphyton at gmail.com
Thu Dec 27 14:38:07 EST 2007



On Dec 27, 8:20 pm, Wildemar Wildenburger
<lasses_w... at klapptsowieso.net> wrote:
>  >
>
>  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 thelist, but thetupledoes not change. It is still atupleof alistand 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)).

That part is ok, I mean it doesn't confuse me I just wanted to say
that this is somewhat confusing behavior.
I agree that its not best put... But I was thinking about the last
part of the post, the part
that talks about trying to print a tuple and getting an error.





More information about the Python-list mailing list