> Why not just write is simply as (1, 2, 3) instead of
> the confusing (1, *(2, 3))?
It is a contrived example. In practice it would be
something more like:
>>> def ts(*t):
... return t
...
>>> x = (2, 3)
>>> y = (1, *x)
File "", line 1
SyntaxError: can use starred expression only as assig
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?
_
What is the idiomatic way to write the right side of
(a, b) = (l[0:2], l[2:])
?
(not worried about the parens, just the splitting of the sequence)
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor