[Python-ideas] Allow filter(items)

Stephen J. Turnbull stephen at xemacs.org
Wed Aug 7 10:43:12 CEST 2013


Shane Green writes:

 > we should consider adding an in-place “filter(predicate=None)”
 > method to list

-1 on the default.

One of the things I like about Python is that it mostly manages to
eschew magic values (like "None" meaning "bool") and spurious brevity
(like defaulting the predicate).  While "bool" may be the most common
predicate here, it's not obvious to me what the absence of the
predicate means.  On both counts, I'm against this (or any) default.

Specifically, in most of the applications where I personally would
want to use something like "filter", zeros and empty lists are typically
valid values.  So I'd want to filter "None" or similar "not available"
values.  Therefore I would expect "is not None" to be the default.

Steve


More information about the Python-ideas mailing list