Stats

202 Contributors: 6
2016-12-15
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook

Filter

Download python eBook

Syntax

  • filter(function, iterable)
  • itertools.ifilter(function, iterable)
  • future_builtins.filter(function, iterable)
  • itertools.ifilterfalse(function, iterable)
  • itertools.filterfalse(function, iterable)

Parameters

ParameterDetails
functioncallable that determines the condition or None then use the identity function for filtering (positional-only)
iterableiterable that will be filtered (positional-only)

Remarks

In most cases a comprehension or generator expression is more readable, more powerful and more efficient than filter() or ifilter().

Related Examples