[Python-Dev] itertools predicates (original) (raw)
Terry Reedy tjreedy at udel.edu
Wed Nov 2 19:59:40 EDT 2016
- Previous message (by thread): [Python-Dev] itertools predicates
- Next message (by thread): [Python-Dev] itertools predicates
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/2/2016 6:03 PM, Francisco Couzo wrote:
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: * Either remove None as a predicate parameter, which would not be backwards compatible. * Or make the functions that don't accept None start accepting it.
I think you should post this as an enhancement proposal on the tracker. Put Raymond Hettinger, the itertools originator and maintainer, as nosy.
-- Terry Jan Reedy
- Previous message (by thread): [Python-Dev] itertools predicates
- Next message (by thread): [Python-Dev] itertools predicates
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]