[Python-ideas] Generator unpacking

Chris Angelico rosuav at gmail.com
Mon Feb 15 03:50:57 EST 2016


On Mon, Feb 15, 2016 at 6:33 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Curious about what would happen, I tried
>
>>>> [] = 42
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: 'int' object is not iterable
>
> So it appears that [] = something is a cute way of asserting
> that the rhs is iterable without consuming anything from it!

Yeah... uhh... "iter(x)" is a less cute way of asserting that it's iterable :D

ChrisA


More information about the Python-ideas mailing list