News for hackers. Stuff that matters.
Re:Functools – The Power of Higher-Order Functions in Python by formerly_proven on Friday July 09, 2021 @06:47AM (#27782349)

    filter(fn): [x for x in foo if fn(x)]
Python has filter(predicate, iterable) -> iterable built in.
Re:Functools – The Power of Higher-Order Functions in Python by quietbritishjim on Friday July 09, 2021 @06:56AM (#27782392)
Absolutely but it's not "Pythonic". Guido said:

> About 12 years ago, Python aquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches. But, despite of the PR value, I think these features should be cut from Python 3000.

("Python 3000" was the code name for Python 3.) He eventually stepped back from this hard line view but it remains a fact that it's a bit of a historical accident that it's present at all.

[1] https://www.artima.com/weblogs/viewpost.jsp?thread=98196

Re:Functools – The Power of Higher-Order Functions in Python by Zababa on Friday July 09, 2021 @09:32AM (#27783479)
The thing is, filter is present in almost all languages now while list comprehensions are in Python, Julia and Haskell. Maybe it's not "pythonic", but Python doesn't exist in a vacuum and is influenced by other languages, as proven with the optional typing and the pattern matching. Maybe it's time to review the definition of pythonic?