[Python-ideas] Generator unpacking

Ethan Furman ethan at stoneleaf.us
Tue Feb 16 13:29:19 EST 2016


On 02/16/2016 11:07 AM, Sven R. Kunze wrote:

 > Another aspect, I came to think of is the following asymmetry:
 >
 > a, b, c, d = mylist4 # works
 > a, b, c = mylist3    # also works
 > a, b = mylist2       # works too
 > [a] = mylist1        # special case?

The asymmetry is because you are mixing two different techniques:

a, b, c, d = mylist4
a, b, c = mylist3
a, b = mylist2
a, = mylist1

or

[a, b, c, d] = mylist4
[a, b, c] = mylist3
[a, b] = mylist2
[a] = mylist1

--
~Ethan~


More information about the Python-ideas mailing list