Partition list with predicate

Terry Reedy tjreedy at
Wed Apr 23 21:10:04 CEST 2008

"Jared Grubb" <jared.grubb at> wrote in message 
news:925822270804230959v557ec5f5re02737709f94d3c6 at
| I want a function that removes values from a list if a predicate 
| to True.

Forget the rigamarole you posted, which has several defects.
If you must modify the list in place, because you have multiple references 
to it:

lst[:] = filter(lambda x: not pred(x), lst)

Otherwise, just lst = filter(....)


More information about the Python-list mailing list