[Python-ideas] Generator unpacking
Chris Angelico
rosuav at gmail.com
Wed Feb 17 11:36:08 EST 2016
On Thu, Feb 18, 2016 at 3:26 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Did you mean the trailing comma is necessary in the one-tuple case?
>
> --> a, b, c = range(3)
> --> a
> 0
> --> b
> 1
> --> c
> 2
>
> --> a = range(1)
> --> a
> [0]
> --> a, = range(1)
> --> a
> 0
>
> --
> ~Ethan~
Correct. It's optional in every other case, but mandatory in the
one-element case.
Chrisa
More information about the Python-ideas
mailing list