[Python-ideas] How assignment should work with generators?
dmoisset at machinalis.com
Mon Nov 27 08:44:28 EST 2017
On 27 November 2017 at 06:40, Chris Angelico <rosuav at gmail.com> wrote:
> Here are a few syntaxes that I believe have been proposed at various
> x, y = islice(iter, 2) # status quo
> x, y = iter # your proposal
> x, y, = iter # omit last destination
Just to clear the list, this one (trailing comma) would be
ambiguous/backward incompatible for the 1 variable case:
x, = iter
which is a relatively common idiom and is expected to raise an error if the
iterator has trailing elements.
Daniel F. Moisset - UK Country Manager - Machinalis Limited
Skype: @dmoisset T: + 44 7398 827139
1 Fore St, London, EC2Y 9DT
Machinalis Limited is a company registered in England and Wales. Registered
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas