[Python-ideas] Add lookahead iterator (peeker) to itertools
Antoine Pitrou
solipsis at pitrou.net
Mon Feb 25 19:53:02 CET 2013
More information about the Python-ideas mailing list
Mon Feb 25 19:53:02 CET 2013
- Previous message: [Python-ideas] Add lookahead iterator (peeker) to itertools
- Next message: [Python-ideas] Add lookahead iterator (peeker) to itertools
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 25 Feb 2013 13:58:59 +0200 Serhiy Storchaka <storchaka at gmail.com> wrote: > On 25.02.13 12:07, Antoine Pitrou wrote: > > Le Sun, 24 Feb 2013 22:41:48 -0500, > > Terry Reedy <tjreedy at udel.edu> a écrit : > >> > >> def test_lookahead(): > >> it = lookahead('abc') > >> while it: > >> a = it.peek > >> b = next(it) > >> print('next:', b, '; is peek:', a is b ) > > > > def test_lookahead(): > > it = iter('abc') > > while True: > > it, peeking = itertools.tee(it) > > This should be outside a loop. Only if you restrict yourself to access peeking each time you access it. (which, I suppose, is not the general use case for the lookahead proposal) Regards Antoine.
- Previous message: [Python-ideas] Add lookahead iterator (peeker) to itertools
- Next message: [Python-ideas] Add lookahead iterator (peeker) to itertools
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list