Lie Ryan wrote: > Jabin Jezreel wrote: >> I am not allowed to do >>>>> t = (1, *(2, 3)) >> >> But I am allowed to do >>>>> def ts(*t): >> .... return t >> .... >>>>> ts(1, *(2, 3)) >> (1, 2, 3) >> >> I realize I can do >>>>> (1,) + (2,3) >> (1, 2, 3) >> >> What is the rationale behind not having t = (1, *(2, 3)) >> have the same semantics as the "ts" case above?
> I guess because it is not clear what (1, *(2, 3)) should mean. > Parentheses when used for function call has different semantic then when > parentheses is used for tuple syntax. Parentheses in function is part of > the calling syntax, while parentheses in tuple is used only for grouping. I'm not sure that's a strong argument against allowing "unfolding" tuples in any expression beyond function calls, though, but it is how Python works. > PS: anyway I just realized that since tuple is immutable, having (1, > *(2, 3)) be (1, 2, 3) would violate immutability. Maybe a list would be > a better example. No, it doesn't. This would be the expression for constructing a new tuple, which would, after that point, be immutable. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor