[Python-ideas] Allow filter(items)

Peter Otten __peter__ at web.de
Mon Aug 5 09:46:03 CEST 2013


filter(items)

looks much cleaner than

filter(None, items)

and is easy to understand. Fewer people would use alternative spellings like 

filter(bool, items) 
filter(len, items)
filter(lambda s: s != "", strings)

The signature change may lead you to spell

filter(predicate, items) # correct

as 

filter(items, predicate) # wrong

but this is a noisy error. I think the advantage of making the magic None 
redundant outweighs this potential pitfall.



More information about the Python-ideas mailing list