inverse of izip
Steven Bethard
steven.bethard at gmail.com
Thu Aug 19 13:17:11 EDT 2004
Peter Otten <__peter__ at web.de> wrote in message news:<cg1pct$p58$00$1 at news.t-online.com>...
> However, your sample data is badly chosen. Unless I have made a typo
> repeating your demo, you are getting the same (last) sequence twice due to
> late binding of i.
>
[snip]
> >>> map(list, starzip(it.izip("123", "abc")))
> [['1', '2', '3'], ['a', 'b', 'c']]
> >>> x, y = starzip(it.izip("123", "abc"))
> >>> list(x)
> ['a', 'b', 'c']
> >>> list(y)
> ['a', 'b', 'c']
> >>>
I knew there was something funny about binding in generators, but I
couldn't remember what... Could you explain why 'map(list, ...)'
works, but 'x, y = ...' doesn't? I read the PEP, but I'm still not
clear on this point.
Thanks,
Steve
More information about the Python-list
mailing list