Re: dropwhile question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: dropwhile question

    Fredrik Lundh wrote:
    maybe you meant to use itertools.ifilt er?
    >
    >>help(itertool s.ifilter)
    Help on class ifilter in module itertools:
    >
    class ifilter(__built in__.object)
    | ifilter(functio n 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.
    >
    >>list(itertool s.ifilter(lambd a x: x<5,range(10)) )
    [0, 1, 2, 3, 4]
    >>list(itertool s.ifilter(lambd a x: 2<x<5,range(10) ))
    [3, 4]
    or, more likely, ifilterfalse:
    >>list(itertool s.ifilterfalse( lambda x: x<5,range(10)) )
    [5, 6, 7, 8, 9]
    >>list(itertool s.ifilterfalse( lambda x: 2<x<5,range(10) ))
    [0, 1, 2, 5, 6, 7, 8, 9]

    </F>

Working...