Nested iteration?

Joshua Landau joshua.landau.ws at gmail.com
Tue Apr 23 17:41:00 EDT 2013


On 23 April 2013 22:29, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:

> I just thought I'd add that Python 3 has a convenient way to avoid
> this problem with next() which is to use the starred unpacking syntax:
>
> >>> numbers = [1, 2, 3, 4]
> >>> first, *numbers = numbers
>

That creates a new list every time. You'll not want that over
try-next-except if you're doing this in a loop, and on addition (if you
were talking in context) your method will exhaust the iterator in the outer
loop.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130423/93fdfe20/attachment.html>


More information about the Python-list mailing list