[Tutor] t = (1, *(2, 3))

Larry Riedel Larry at Riedel.org
Fri May 15 00:02:52 CEST 2009


> > >>> x = (2, 3)
> > >>> y = (1, *x)
> >  File "<stdin>", line 1
> > SyntaxError: can use starred expression only as assignment target
>
> But you can already do that without needing to extend * notation
> to work like that

To me the "*" notation already /appears/ to work like that:
(Python 3.x)
    >>> a = [1, 2, 3]
    >>> (b, *c) = a
    >>> b
    1
    >>> c
    [2, 3]

Just only in one direction.

    >>> a = (b, *c)
      File "<stdin>", line 1
    SyntaxError: can use starred expression only as assignment target


Larry


More information about the Tutor mailing list