[Python-Dev] itertools predicates (original) (raw)

Francisco Couzo franciscouzo at gmail.com
Wed Nov 2 18:03:27 EDT 2016


Some functions that take a predicate from itertools accept None as its predicate:

list(itertools.filterfalse(None, range(10))) [0] list(itertools.groupby([0,0,1,1], None)) [(0, <itertools._grouper object at 0x7fedc2047198>), (1, <itertools._grouper object at 0x7fedc2 0471d0>)]

While others don't:

list(itertools.dropwhile(None, range(10))) Traceback (most recent call last): File "", line 1, in TypeError: 'NoneType' object is not callable

I'd be interested in writing a patch to make itertools more consistent if there's a consensus.

I see two possible solutions:



More information about the Python-Dev mailing list