[Python-ideas] iterable.__unpack__ method

Guido van Rossum guido at python.org
Sun Feb 24 07:24:50 CET 2013


But is that really so much better than

  command = next(iterargs)
  # etc.

?

And to me the ... Looks too much like something that consumes the rest,
rather than leaving it.

--Guido (not on a real keyboard)

On Saturday, February 23, 2013, Nick Coghlan wrote:

> On Sun, Feb 24, 2013 at 12:12 PM, Nick Coghlan <ncoghlan at gmail.com<javascript:;>>
> wrote:
> > I definitely like Terry's idea of using ", ..." to say "and ignore the
> > rest". Simple, elegant and can be restricted to the last element so it
> works
> > with infinite iterators and large sequences. It also allows incremental
> > unpacking of ordinary iterators.
>
> I want to expand on this a bit now I'm back on a real computer, since
> it wasn't immediately obvious to me how well the ", ..." proposal
> supports incremental unpacking, but it became clear once I thought of
> this simple example:
>
>     iterargs = iter(args)
>     command, ... = iterargs # Grab the first element, leave the rest
> in the iterator
>     commands[command](*iterargs) # Pass the rest to the command
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan at gmail.com <javascript:;>   |   Brisbane,
> Australia
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org <javascript:;>
> http://mail.python.org/mailman/listinfo/python-ideas
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130223/697dbc08/attachment.html>


More information about the Python-ideas mailing list