[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico
Matteo Dell'Amico added the comment: great Raymond! :) ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Georg Brandl
Georg Brandl added the comment: Shame on me, I forgot about the optional argument too. ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread David W. Lambert
David W. Lambert added the comment: Nice. I had thought of this a while ago but found counter example, probably using the empty iterator def f(): raise StopIteration yield I didn't realize "next" had optional argument. ___ Python tracker

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: Applied in r69908 . -- resolution: -> accepted status: open -> closed ___ Python tracker ___ ___

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread David W. Lambert
Changes by David W. Lambert : -- nosy: +LambertDW ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico
Matteo Dell'Amico added the comment: Georg, you're right, there's a StopIteration to catch. My thinko was mistaking the function for a generator where the exception propagation would have done the right thing. The amended version now becomes next(b) for x, y in zip(a, b): yield x, y ...which i

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Georg Brandl
Georg Brandl added the comment: Assigning to Raymond. Note that "for elem in b: break" and "next(b)" are not equivalent when b is empty/exhausted. -- assignee: georg.brandl -> rhettinger nosy: +rhettinger ___ Python tracker

[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico
New submission from Matteo Dell'Amico : I feel that the "pairwise" recipe could be slightly more elegant if "for elem in b: break" became a simpler next(b) (or b.next() for Python 2.x). It is also more natural to modify the recipes to suit one's needs (e.g., returning items with a given gap betwe