Re: Find the first element that meets the condition

2007-02-25 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I have a list and I want to find the first element that meets a > condition. I do not want to use 'filter', because I want to come out > of the iteration as soon as the first element is found. > I have implemented it this way, may be, there should b

Re: Find the first element that meets the condition

2007-02-25 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I have a list and I want to find the first element that meets a > condition. I do not want to use 'filter', because I want to come out > of the iteration as soon as the first element is found. > I have implemented it this way, may be, there should be a built in > hiding

Re: Find the first element that meets the condition

2007-02-25 Thread Troy Melhase
> I have implemented it this way, may be, there should be a built in > hiding somewhere in the standard libraries? the itertools module might have what you're after. something similar to your example: >>> import itertools >>> r = iter(range(100)) >>> n = itertools.dropwhile(lambda x:x<=13, r) >>

Find the first element that meets the condition

2007-02-25 Thread [EMAIL PROTECTED]
Hi, I have a list and I want to find the first element that meets a condition. I do not want to use 'filter', because I want to come out of the iteration as soon as the first element is found. I have implemented it this way, may be, there should be a built in hiding somewhere in the standard librar