Loading...
 

filter

In water quality a filter device is used to remove contaminants and pollutants.

programming use


According to the creator of the Python language, a "filter(P, S) is almost always written clearer as x for x in S if P(x), and this has the huge advantage that the most common usages involve predicates that are comparisons, e.g. x==42, and defining a lambda for that just requires much more effort for the reader (plus the lambda is slower than the list comprehension).

Even more so for map(F, S) which becomes F(x) for x in S. Of course, in many cases you'd be able to use generator expressions instead."