it works exactly as specified:[5, 6, 7, 8, 9]>>>list(itertools.dropwhile(lambda x: x<5,range(10)))
Why doesn't this work?
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>list(itertools.dropwhile(lambda x: 2<x<5,range(10)))
Help on class dropwhile in module itertools:>>help(itertools.dropwhile)
class dropwhile(__builtin__.object)
| dropwhile(predicate, iterable) --dropwhile object
|
| Drop items from the iterable while predicate(item) is true.
| Afterwards, return every element until the iterable is exhausted.
False>>2<0<5
maybe you meant to use itertools.ifilter?
Help on class ifilter in module itertools:>>help(itertools.ifilter)
class ifilter(__builtin__.object)
| ifilter(function or None, sequence) --ifilter object
|
| Return those items of sequence for which function(item) is true.
| If function is None, return the items that are true.
[0, 1, 2, 3, 4]>>list(itertools.ifilter(lambda x: x<5,range(10)))
[3, 4]>>list(itertools.ifilter(lambda x: 2<x<5,range(10)))
</F>