[a,b,c,d] = 1,2,3,4
Joel Goldstick
joel.goldstick at gmail.com
Tue Aug 25 10:30:56 EDT 2015
- Previous message (by thread): [a,b,c,d] = 1,2,3,4
- Next message (by thread): [a,b,c,d] = 1,2,3,4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Tue, Aug 25, 2015 at 10:16 AM, ast <nomail at invalid.com> wrote:
>>>> [a,b,c,d] = 1,2,3,4
>>>> a
>
> 1
>>>>
>>>> b
>
> 2
>>>>
>>>> c
>
> 3
>>>>
>>>> d
>
> 4
>
> I have never seen this syntax before. Is it documented.
> Is there a name for that ?
>
> thx
> --
> https://mail.python.org/mailman/listinfo/python-list
its called list unpacking or packing (?)
the right side is considered a tuple because of the commas
>>> a = 1,2,3
>>> a
(1, 2, 3)
>>> a[1]
2
>>>
http://www.developer.com/lang/other/article.php/630101/Learn-to-Program-using-Python-Unpacking-Tuples.htm
--
Joel Goldstick
http://joelgoldstick.com
- Previous message (by thread): [a,b,c,d] = 1,2,3,4
- Next message (by thread): [a,b,c,d] = 1,2,3,4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list