Python 3, module 'itertools' has no attribute 'ifilter' Python 3, module 'itertools' has no attribute 'ifilter' python-3.x python-3.x

Python 3, module 'itertools' has no attribute 'ifilter'


itertools.ifilter() was removed in Python 3 because the built-in filter() function provides the same functionality now.

If you need to write code that can run in both Python 2 and Python 3, use imports from the future_builtins module (only in Python 2, so use a try...except ImportError: guard):

try:    # Python 2    from future_builtins import filterexcept ImportError:    # Python 3    passreturn filter(lambda i: i.state == "IS", self.storage)