is_None

iteration_utilities.is_None(value, /)

Returns True if value is None, otherwise False.

Parameters:

value : any type

The value to test for None.

Returns:

is_none : bool

True if value is None otherwise it returns False.

Examples

This function is equivalent to lambda x: x is None but significantly faster:

>>> from iteration_utilities import is_None
>>> is_None(None)
True
>>> is_None(False)
False

This can be used for example to remove all None from an iterable:

>>> import sys
>>> import itertools
>>> filterfalse = itertools.ifilterfalse if sys.version_info.major == 2 else itertools.filterfalse
>>> list(filterfalse(is_None, [1, None, 3, 4, 5, None, 7]))
[1, 3, 4, 5, 7]