Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 86)
86.
How does the itertools.compress() function differ from itertools.filterfalse() when used with generators?
They are equivalent in functionality
itertools.compress() filters elements based on a true condition, while itertools.filterfalse() filters based on a false condition
itertools.filterfalse() filters elements based on a true condition, while itertools.compress() filters based on a false condition
itertools.compress() raises a ValueError if the selectors iterable is shorter than the data iterable
Answer: Option
Explanation:
itertools.compress() filters elements from the data iterable based on corresponding truth values in the selectors iterable. itertools.filterfalse() filters elements based on a false condition.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.