[Tutor] t = (1, *(2, 3))
Jabin Jezreel
jabinjezreel at gmail.com
Thu May 14 20:10:53 CEST 2009
> 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 "<stdin>", line 1
SyntaxError: can use starred expression only as assignment target
>>> y = ts(1, *x)
>>> y
(1, 2, 3)
> Don't say that (2, 3) might be a variable, it
> won't work without breaking python object model.
> If such construct creates a new tuple, it would
> need to break python's object model [...]
Break how?
More information about the Tutor
mailing list