I'm streaming a very large collection through a script and am currently using ifilter
in a simple call to reject certain values, i.e.:
ifilter(lambda x: x in accept_list, read_records(filename))
That's one predicate, but now it's occurred to me I should add another, and I might want to add others in the future. The straightforward way would've been nesting an ifilter
call:
ifilter(lambda x : x not in block_list,
ifilter(lambda x: x in accept_list, read_records(filename)))
I am thinking of simply putting the predicates as unbound functions in a list and using them for this. These repeated ifilter calls seem hard to attain there though (and might not be the best option). Perhaps I can construct a single function that calls all the predicates but how do I write this as concisely (while still readable) as possible?