I don't like it either. Ideally, I would want "returning", but of course a new keyword is not an option for such limited use case. "as" is probably much better, and the behavior of as in other contexts is very similar.
On Tue, 16 Apr 2019 at 23:42, Jan Kaliszewski <z...@kaliszewski.net> wrote: > > Hello, > > 2019-04-16 Stefano Borini <stefano.bor...@gmail.com> dixit: > > > def g(): > > yield 2 > > yield 3 > > return 6 > [...] > > for x in g() return v: > > print(x) > > > > print(v) # prints 6 > > I like the idea -- occasionally (when dealing with `yield > from`-intensive code...) I wish such a shortcut existed. > > I don't like the proposed keyword. Maybe `as` would be better? > > for x in g() as v: > print(x) > > print(v) > > Cheers, > *j > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ -- Kind regards, Stefano Borini _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/