On Tue, Oct 22, 2013 at 9:50 PM, Steven D'Aprano <[email protected]> wrote:
> However, there does have to be the same number of items on both sides:
>
> py> a, b, c = "xy"
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ValueError: need more than 2 values to unpack
3.x extends sequence unpacking to support starred expressions:
>>> a, b, *c = 'xy'
>>> a, b, c
('x', 'y', [])
>>> a, b, *c = 'xyz'
>>> a, b, c
('x', 'y', ['z'])
>>> a, b, c, *rest = 'xyzpdq'
>>> a, b, c, rest
('x', 'y', 'z', ['p', 'd', 'q'])
http://www.python.org/dev/peps/pep-3132
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor