TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Toolz: A functional standard library for Python

84 pointsby Lofkinabout 10 years ago

11 comments

bootheadabout 10 years ago
I love libraries like this and fn.py, and I really miss the things I&#x27;ve got used to having available in Haskell when I write python. It&#x27;s possible to use function patterns in python (Applicative and Functor are things you can implement in any language). However given who is in charge of python and the way he feels about FP, I don&#x27;t think python will ever be a decent functional programming environment:<p><pre><code> As long as I&#x27;m &quot;in charge&quot; the chances of this (or anything like it) being accepted into Python are zero. I get a headache when I try to understand code that uses function composition, and I end up having to laboriously rewrite it using more traditional call notation before I move on to understanding what it actually does. Python is not Haskell, and perhaps more importantly, Python users are not like Haskell users. Either way, what may work out beautifully in Haskell will be like a fish out of water in Python. I understand that it&#x27;s fun to try to sole this puzzle, but evolving Python is more than solving puzzles. Enjoy debating the puzzle, but in the end Python will survive without the solution. </code></pre> <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1017621&#x2F;why-isnt-python-very-good-for-functional-programming" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1017621&#x2F;why-isnt-python-v...</a>
评论 #9531332 未加载
评论 #9530633 未加载
评论 #9530477 未加载
jboynycabout 10 years ago
Between this an fn.py (<a href="https:&#x2F;&#x2F;github.com&#x2F;kachayev&#x2F;fn.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kachayev&#x2F;fn.py</a>), functional programming in Python has really good library support beyond the standard library.
评论 #9531091 未加载
wodenokotoabout 10 years ago
That is not what stemming is at all. Stemming is going from &quot;running&quot; to &quot;run&quot;, not &quot;run!&quot; to &quot;run&quot;<p><a href="http:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Stemming" rel="nofollow">http:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Stemming</a>
评论 #9532227 未加载
pionarabout 10 years ago
It seems to me that if you want functional programming, you choose a functional language. You don&#x27;t (excuse my language) bastardize an OO language for it.
评论 #9531823 未加载
kraymerabout 10 years ago
Tangential but ... could someone give me the name of the python library that made the front page last month and that &quot;extends the standard lib&quot; (itertools recipes, dates helper functions, etc)? Can&#x27;t find it using HN search. Email in my profile. thks
评论 #9530682 未加载
kmike84about 10 years ago
It is sometimes hard to justify a dependency - many of toolz&#x2F;fn.py&#x2F;funcy functions are not hard to write manually.<p>The great thing about toolz is its <a href="https:&#x2F;&#x2F;github.com&#x2F;pytoolz&#x2F;cytoolz" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pytoolz&#x2F;cytoolz</a> counterpart which provides an optimized implementation of toolz. It is useful when you have a bottleneck in Python code - e.g. run several functions (functoolz.juxt), merge dictionaries (dicttooz.merge), etc. With cytoolz the code becomes prettier and faster, not only prettier, so it is easier for cytoolz to sneak in.
评论 #9534199 未加载
mrocklinabout 10 years ago
<a href="http:&#x2F;&#x2F;toolz.readthedocs.org&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">http:&#x2F;&#x2F;toolz.readthedocs.org&#x2F;en&#x2F;latest&#x2F;</a>
nilknabout 10 years ago
I love stuff like this, though I feel it makes the code actually harder to read because none of it&#x27;s standardized and there are a variety of somewhat equivalent but not completely isomorphic libraries out there for functional programming in Python.
calebmabout 10 years ago
Does it have a recursive dictionary merge - something like merge({&#x27;a&#x27;: {&#x27;b&#x27;: 1}}, {&#x27;a&#x27;: {&#x27;c&#x27;: 2}}) -&gt; {&#x27;a&#x27;: {&#x27;b&#x27;: 1, &#x27;c&#x27;: 2}} ?
评论 #9534291 未加载
评论 #9534091 未加载
agumonkeyabout 10 years ago
Year old reddit thread<p><a href="http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;Python&#x2F;comments&#x2F;1wrlji&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;Python&#x2F;comments&#x2F;1wrlji&#x2F;</a>
alvareabout 10 years ago
I always include toolz in my Python projects. It&#x27;s also useful as a compatibility wrapper.