[Python-ideas] How assignment should work with generators?

Daniel Moisset 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
> times:
>
> 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
www.machinalis.co.uk <http://www.machinalis.com>
Skype: @dmoisset T: + 44 7398 827139

1 Fore St, London, EC2Y 9DT

Machinalis Limited is a company registered in England and Wales. Registered
number: 10574987.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171127/7b2fe2c0/attachment.html>


More information about the Python-ideas mailing list