On 27.05.2014 11:05, Chris Angelico wrote: > On Tue, May 27, 2014 at 6:58 PM, Serhiy Storchaka <storchaka at gmail.com> wrote: >> 26.05.14 10:59, raymond.hettinger написав(ла): >>> >>> + result = [(elem, i) for i, elem in zip(range(n), it)] >> >> >> Perhaps it is worth to add simple comment explaining why this is not >> equivalent to just list(zip(it, range(n))). Otherwise it can be >> unintentionally "optimized" in future. >> > > Where is the difference? I'm very much puzzled now. My first thought > was based on differing-length iterables in zip, but the docs say it > stops at the shortest of its args. Nice puzzle. (elem, i) is not (i, elem), though. Thats really hard to see when not looking at it closely. > > ChrisA > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/j.wielicki%40sotecware.net >
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4