[Python-ideas] How assignment should work with generators?
greg.ewing at canterbury.ac.nz
Tue Nov 28 00:07:15 EST 2017
Kirill Balunov wrote:
> So someone too perlish
> clever can assume that with the proposed syntax:
> >>> def gen():
> >>> for i in ['a', 'b', 'c', 'd']:
> >>> v = x if 'x' in globals() else 'var '
> >>> yield v + i
> >>> x, y = gen()
> >>> x
> var a
> >>> y
> var ab
There's no need for that to happen. It can still unpack all the values
it needs before performing any assignments.
More information about the Python-ideas