[New-bugs-announce] [issue25542] tuple unpacking on assignment should be lazy for unpacked generators

Mario Wenzel report at bugs.python.org
Tue Nov 3 07:30:08 EST 2015


New submission from Mario Wenzel:

if I have an assignment
a = <some_generator> then a is the generator. 

But if I do any kind of unpacking
*a, = <some_generator> # a list of all items
a, *aa = <some_generator> # first item in a, list of rest in as

If the right-hand side is a generator expression, I would expect that 
a, *aa unpacks the first element into a and puts the whole generator (having yielded the first element) back into aa.

So the star-operator of tuple unpacking with the right-hand-side having a generator should be lazy and not exhaust the whole generator.

----------
components: Interpreter Core
messages: 253985
nosy: Mario Wenzel
priority: normal
severity: normal
status: open
title: tuple unpacking on assignment should be lazy for unpacked generators
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25542>
_______________________________________


More information about the New-bugs-announce mailing list