TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Boltons: over 100 Python utilities

282 点作者 mhashemi大约 10 年前

16 条评论

drawkbox大约 10 年前
Very nice collection. I like the cacheutils LRI and LRU setups [1]. Interested in the StringBuffer [2]. The Table object looks useful [3]. Overall some great additions in utils that you can tell were added through usage and shipping needs especially in strutils, listutils, formatutils etc. Lots of common ones in our own python or other platform libs.<p>In any review there is always a few WTFs like this one [4]. I am surprised you didn&#x27;t get <i>arrested during that development</i><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;cacheutils.py#L5" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;cache...</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;strutils.py#L282" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;strut...</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;tableutils.py#L180" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;table...</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;easterutils.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;easte...</a>
评论 #9351014 未加载
pyre大约 10 年前
This doesn&#x27;t seem portable: <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;tests&#x2F;table_html_app.py#L8" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;tests...</a>
评论 #9352209 未加载
评论 #9351751 未加载
评论 #9351718 未加载
评论 #9352000 未加载
cool-RR大约 10 年前
Quite similar to my project, Python Toolbox:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;cool-RR&#x2F;python_toolbox" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cool-RR&#x2F;python_toolbox</a><p>It supports Python 3.
评论 #9355806 未加载
评论 #9357368 未加载
评论 #9353681 未加载
nuclear_eclipse大约 10 年前
Really like the concept, and would love to use this in some of my projects, but no Python 3 support.... :&#x27;(
评论 #9351351 未加载
评论 #9357355 未加载
hamiltonkibbe大约 10 年前
I&#x27;d been wondering how to do this... <a href="https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;easterutils.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mahmoud&#x2F;boltons&#x2F;blob&#x2F;master&#x2F;boltons&#x2F;easte...</a>
geoelectric大约 10 年前
Very nice. These solve a number of small but real problems and it looks like a great utility package!<p>I think the docs of iterutils.split() vs. iterutils.split_iter() might be a little off.<p>They both claim to return lists but split_iter() says if you want lists, see split(). Without having installed the package yet, my guess is split_iter() returns an iterator. Either way, the docs are contradictory.<p><a href="https:&#x2F;&#x2F;boltons.readthedocs.org&#x2F;en&#x2F;latest&#x2F;iterutils.html#iteration" rel="nofollow">https:&#x2F;&#x2F;boltons.readthedocs.org&#x2F;en&#x2F;latest&#x2F;iterutils.html#ite...</a><p>Thanks for this!
评论 #9351616 未加载
评论 #9351612 未加载
HZet0r大约 10 年前
There is a LRU cache in the standard library starting in 3.2: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;functools.html#functools.lru_cache" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;functools.html#functools.l...</a><p>Doesn&#x27;t have quite the same options, but arguably nicer to use because it&#x27;s a decorator.
评论 #9353011 未加载
_0ffh大约 10 年前
&quot;The :class:`set` type brings brings the practical expressiveness of set theory to Python. It has a very rich API overall, but lacks a couple of fundamental features. For one, sets are not ordered. On top of this, sets are not indexable&quot;<p>I suppose that may be because sets are not supposed to be ordered. Nor indexable.
评论 #9353326 未加载
lqdc13大约 10 年前
I like the spirit, however a lot of these can be done with a simple one liner... Example for chunked iteration:<p>```<p>def chunk_iter(some_seq, n):<p><pre><code> return (seq[pos:pos + n] for pos in range(0, len(seq), n)) </code></pre> ```<p>example for multi-dict: (unless I&#x27;m missing something)<p>```<p>from collections import defaultdict<p>d = defaultdict(list)<p>d[&#x27;a&#x27;].append(&#x27;b&#x27;)<p>d[&#x27;a&#x27;].append(&#x27;c&#x27;)<p>dict(d)<p>{&#x27;a&#x27;: [&#x27;b&#x27;, &#x27;c&#x27;]}<p>```
评论 #9352331 未加载
评论 #9353068 未加载
thinxer大约 10 年前
Python really need something like Go&#x27;s official libraries. I mean those with a prefix &quot;golang.org&#x2F;x&#x2F;&quot;. Those libraries update more often than stdlibs but still provide a concrete common ground for developers. It is like &quot;evergreen&quot; stdlibs.
评论 #9352449 未加载
ekimekim大约 10 年前
So glad someone did something like this and made it presentable enough for widespread usage.<p>In contrast, my own &quot;utils&quot; libraries[1] are often too specific, or not well documented. However, there&#x27;s already some overlap (eg. I had my own version of funutils.mro_items()), and later today I&#x27;ll take a look through and see what of mine might be a candidate for inclusion.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;ekimekim&#x2F;pylibs&#x2F;tree&#x2F;master&#x2F;libs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ekimekim&#x2F;pylibs&#x2F;tree&#x2F;master&#x2F;libs</a>
评论 #9352356 未加载
justanother大约 10 年前
Is that their real name?<p>Are they related to that singer guy?
lifeisstillgood大约 10 年前
So glad to see this - there are things here I thought I was weird for having to make and want myself - liked chunked iterations. I assumed there as something wrong with me ... Glad to see it&#x27;s not just me<p>Nice one
eiopa大约 10 年前
These are great!<p>You know, this makes me thing about how there are so many things that I wish Python would come with: requests, lxml, gevents and a good amount of stuff from the package.<p>I wish there was Python 2.8.
评论 #9353128 未加载
wrsh07大约 10 年前
Where are the tests?
评论 #9351378 未加载
asah大约 10 年前
wow, this is awesome.<p>boltons.tableutils has a lot of TODOs - if you like the concept, the littletable package [1] takes the concept of a python query language pretty far. I put it in production and extended it even further [2]. We&#x27;d both welcome help &#x2F; pull requests.<p>[1] <a href="https:&#x2F;&#x2F;www.google.com&#x2F;search?q=python+littletable" rel="nofollow">https:&#x2F;&#x2F;www.google.com&#x2F;search?q=python+littletable</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;asah&#x2F;littletable" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;asah&#x2F;littletable</a>