inverse of izip

Steven Bethard steven.bethard at gmail.com
Thu Aug 19 03:04:45 EDT 2004


On Thu, 19 Aug 2004 12:07:48 +0530, Satchidanand Haridas
<sharidas at zeomega.com> wrote:
> 
> >>> a = itertools.izip(*itertools.izip(range(10),range(10)))
> >>> a
> <itertools.izip object at 0x40164f2c>
> 
> >>>a.next()
> (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
> >>> a.next()
> (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
> >>> a.next()

I'm assuming you popped this one off without actually reading my
email.  No worries - it happens some times.  You'll note however, that
this is exactly what I said didn't work:

Steven Bethard wrote:
>>>>x, y = itertools.izip(*itertools.izip(range(10), range(10)))
>>>>x, y
>((0, 1, 2, 3, 4, 5, 6, 7, 8, 9), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
>
>But then I get a pair of tuples, not a pair of iterators.  Basically,
>I want to convert an iterator of tuples into a tuple of iterators.

I want the elements returned by the itertools.izip object to be
iterators, not tuples or lists.

Steve

-- 
You can wordify anything if you just verb it.
        - Bucky Katt, Get Fuzzy



More information about the Python-list mailing list