"[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
[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
> 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)
>>