Ask HN: What are some unusual but useful Python libraries you've discovered?
1–10 of 19 posts
Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#2Audio track seperation:
https://github.com/adefossez/demucs
demucs works pretty well.
Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#3Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#4context: OpenAI API used to be super flaky back in the early days, i needed to retry my requests quite frequently and i found this
Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#5Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#6I really like xmltodict (https://github.com/martinblech/xmltodict). Despite the name, it works in both directions. It is the most ergonomic library I have used for creating XML. It has external type stubs: https://pypi.org/project/types-xmltodict/.
Since you have recently discovered Rich, you may want rich-argparse (https://github.com/hamdanal/rich-argparse). It colorizes argparse CLIs with little effort from the user.
DeepDiff (https://github.com/seperman/deepdiff) has helped me with testing. I needed to compare two nested data structures but ignore any differences in floats (timestamps). DeepDiff let me do it:
diff = DeepDiff(
run_session(config), run_session(config, force=True), exclude_types=(float,)
)
assert not diff
pzp (https://github.com/andreax79/pzp) is like fzf in pure Python to use in your programs.
Keep in mind it is currently version 0.0.x.
I have found bugs, but I think it is just cool that it exists.Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#7Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#8I use https://github.com/litl/backoff for configurable backoff + retry context: OpenAI API used to be super flaky back in the early days, i needed to retry my requests quite frequently and i found this
I have used two libraries for retrying in Python: retry (https://github.com/invl/retry) and Tenacity (https://github.com/jd/tenacity). Tenacity actually helped me with a recent GPT-4o mini experiment, when OpenRouter gave me an error after a couple hundred requests. I can recommend Tenacity. A downside is that the API is fairly complex and verbose. You will probably look it up each time if you don't use it often (or rely on an IDE or LLM).
Backoff seems somewhat less flexible than Tenacity (https://github.com/litl/backoff/issues/125) but more concise. Basic use requires as little code as retry and should be easy to remember.
Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#9Re: Ask HN: What are some unusual but useful Python libraries you've discovered?
#10The alternative is either you maintain two interfaces with boilerplate, or write a cli only if that’s the first priority.
Similar solutions exist, like fire. But fire’s cli is like an afterthought, in the sense it gives people a way to run things in command line where they already know how to run it from Python.