Re: dropwhile question

2008-08-23 Thread Rajanikanth Jammalamadaka
Thanks for the explanations. Regards, Raj On Sat, Aug 23, 2008 at 3:41 PM, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Rajanikanth Jammalamadaka wrote: > > list(itertools.dropwhile(lambda x: x<5,range(10))) >> >> [5, 6, 7, 8, 9] >> >> Why doesn't this work? > > list(itertool

Re: dropwhile question

2008-08-23 Thread Scott David Daniels
Rajanikanth Jammalamadaka wrote: list(itertools.dropwhile(lambda x: x<5,range(10))) [5, 6, 7, 8, 9] Why doesn't this work? list(itertools.dropwhile(lambda x: 2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Because it drops _while_ the condition is True (which it is for the first 0 entries in the sequence).

Re: dropwhile question

2008-08-23 Thread Fredrik Lundh
Fredrik Lundh wrote: maybe you meant to use itertools.ifilter? >>> help(itertools.ifilter) Help on class ifilter in module itertools: class ifilter(__builtin__.object) | ifilter(function or None, sequence) --> ifilter object | | Return those items of sequence for which function(item) is

Re: dropwhile question

2008-08-23 Thread Fredrik Lundh
Rajanikanth Jammalamadaka wrote: list(itertools.dropwhile(lambda x: x<5,range(10))) [5, 6, 7, 8, 9] Why doesn't this work? > list(itertools.dropwhile(lambda x: 2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] it works exactly as specified: >>> help(itertools.dropwhile) Help on class dropwhile in module i

Re: dropwhile question

2008-08-23 Thread Marc 'BlackJack' Rintsch
On Sat, 23 Aug 2008 14:54:09 -0700, Rajanikanth Jammalamadaka wrote: list(itertools.dropwhile(lambda x: x<5,range(10))) > [5, 6, 7, 8, 9] > > Why doesn't this work? list(itertools.dropwhile(lambda x: 2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] It *does* work. `dropwhile()` drops as long as the c

dropwhile question

2008-08-23 Thread Rajanikanth Jammalamadaka
>>> list(itertools.dropwhile(lambda x: x<5,range(10))) [5, 6, 7, 8, 9] Why doesn't this work? >>> list(itertools.dropwhile(lambda x: 2http://mail.python.org/mailman/listinfo/python-list