I really love the wave of new tools that are gaining traction in the Python world: tqdm, rich (and soon textual), fastpi, typer, pydantic, shiv, toga, doit, diskcache...
With the better error messages in 3.10 and 11, plus the focus on speed, it's a fantastic era for the language and it's a ton of fun.
I didn't expect to find back the feeling of "too-good-to-be-true" I had when starting with 2.4, and yet.
In fact, being a dev is kinda awesome right now, no matter where you look. JS and PHP are getting more ergonomics, you get a load of new low level languages to sharpen your hardware, Java is modern now, C# runs on Unix, the Rust and Go communities are busy with shipping fantastic tools (ripgrep, fdfind, docker, cue, etc), windows has a decent terminal and WSL, my mother is actually using Linux and Apple came up with the M1. IDEs and browsers are incredible, and they do eat a lot of space, but I have a 32 Go RAM + 1TO SSD laptop that's as slim as a sheet of paper.
Not to mention there is a lot of money to be made.
I know it's trendy right now to say everything is bad in IT, but I disagree, overall, we have it SO good.
doit [0] is a superb toolkit for building task-oriented tools with dependencies. It isn't too complex to get started and gives you a lot to work with. I've used it for an internal tool used by everyone in the company for 5+ years and it has never given me a headache.
I'll add BeeWare (https://beeware.org/) as a pretty nice nice to deploy Python applications cross-platform easily. It's more like a suite of tools, though.
I love Python for many things: scripts, data science, prototypes, etc. But I would never use it to build a large backend system. I just can't handle all the warts. Yes it has been used by large companies, but not without their problems.
wow, didn't know this existed. I've been using ipython as shell-ish replacement for not-so-serious-thing. I need to take a detail look at this from my initial glance over. thanks
If you like tqdm, it's worth checking out pqdm, a parallelized version. If you have embarrassingly parallel work to process in a script, it makes it dead simple to parallelize and monitor the progress of something. Highly recommend:
+1 for PQDM, I use it a ton and most of the time it just works. I did have some rare cases where PQDM was much slower than a direct joblib implemention, but that could well be a fluke on my end. Either way, amazing package!
My current issue with tqdm is nested progress bars in multi-threading/processing causing dead locks + tqdm.write just being broken in those contexts, either deadlocking or the ui just being wrong. Does pqdm do a better job?
Python is such an amazing language, on one hand, it's easy enough where you could probably train a non technical person on it within about two months.
Yet, you can still make 200K writing it, I don't know the next time I'll create a command line application in Python, but I'll keep this little tool in mind. I hope Python eats the world.
it may be easy to get going with python, but it takes a non trivial amount of time to understand, what is going on. I have a advanced python3 course https://github.com/MoserMichael/python-obj-system that explains some of the more advanced concepts. One of the things covered are decorators (tqdm is a decorator)
Check out Will Chrichton's talk "Type-Driven API Design in Rust" where he live-codes a tqdm-like progress bar for Rust iterators. Solid presentation and eye-opening how straightforward it was to extend the core language through traits.
tqdm is one of the very few Python packages that makes it into every script I write. It's a very high ROI for managing and tracking simple loops.
My only complaint is the smoothing parameter; by default it predicts the estimated time remaining based on the most recent updates so it can fluctuate wildly; smoothing=0 predicts based on the total runtime which makes more sense given law of large numbers.
Is there a way to globally disable all tqdm progress bars?
Something like the NO_COLOR environement variable?
These progress bars are nice when you launched a single loop yourself, but when you are running an automated battery of many things they become annoying and pollute your terminal too much. I know that you can silence each particular program that uses tqdm by setting a 'disable' option. But this requires editing the python source code of the program.
import os
import sys
from tqdm import tqdm as _tqdm
def tqdm(*args, **kwargs):
try:
disable = bool(int(os.environ['NO_PROGRESSBARS']))
except KeyError:
disable = not sys.stdout.isatty()
except (ValueError, TypeError):
disable = False
kwargs.setdefault('disable', disable)
return _tqdm(*args, **kwargs)
Then import that instead of tqdm.tqdm.
sys.stdout.isatty() isn't a perfect answer to what people ask when they want to know "am I running in an automated environment, or is a human user looking at my output?", but it's close. More nuance is available online.
I like how tqdm can manage multiple progressbars in the same terminal. I have used it to track the progress of multi day processes. It also produces a nice animation on jupyter notebooks.
[+] [-] BiteCode_dev|4 years ago|reply
With the better error messages in 3.10 and 11, plus the focus on speed, it's a fantastic era for the language and it's a ton of fun.
I didn't expect to find back the feeling of "too-good-to-be-true" I had when starting with 2.4, and yet.
In fact, being a dev is kinda awesome right now, no matter where you look. JS and PHP are getting more ergonomics, you get a load of new low level languages to sharpen your hardware, Java is modern now, C# runs on Unix, the Rust and Go communities are busy with shipping fantastic tools (ripgrep, fdfind, docker, cue, etc), windows has a decent terminal and WSL, my mother is actually using Linux and Apple came up with the M1. IDEs and browsers are incredible, and they do eat a lot of space, but I have a 32 Go RAM + 1TO SSD laptop that's as slim as a sheet of paper.
Not to mention there is a lot of money to be made.
I know it's trendy right now to say everything is bad in IT, but I disagree, overall, we have it SO good.
[+] [-] dogline|4 years ago|reply
- tqdm: progress bars (https://tqdm.github.io/)
- rich: text formatting (https://github.com/willmcgugan/rich)
- textual: TUI, using rich (https://github.com/willmcgugan/textual)
- fastpi: Rest APIs (https://fastapi.tiangolo.com/)
- typer: CLI Library, uses Click (https://typer.tiangolo.com/)
- pydantic: Custom data types (https://pydantic-docs.helpmanual.io/)
- shiv: Create Python zipapps (https://shiv.readthedocs.io/en/latest/)
- toga: GUI Toolkit (https://toga.readthedocs.io/en/latest/)
- doit: Task runner (https://pydoit.org/)
- diskcache: A disk cache (https://github.com/grantjenks/python-diskcache/)
[+] [-] trutannus|4 years ago|reply
[+] [-] systemvoltage|4 years ago|reply
I can go home with Python at 5pm. And have a good time with my family.
[+] [-] axg11|4 years ago|reply
[+] [-] rbdixon|4 years ago|reply
[0]: https://pydoit.org
[+] [-] MichaelMoser123|4 years ago|reply
[+] [-] ropable|4 years ago|reply
[+] [-] hpen|4 years ago|reply
[+] [-] iooi|4 years ago|reply
[+] [-] smus|4 years ago|reply
[+] [-] jansky|4 years ago|reply
Rich is just amazing library
[+] [-] fnord77|4 years ago|reply
[+] [-] make3|4 years ago|reply
[+] [-] karmasimida|4 years ago|reply
[+] [-] jasonpeacock|4 years ago|reply
No more bash! No more subprocess! Write shell-like code with the convenience of Python!
Seriously, it's a great module. A bit of a learning curve, but then it feels natural.
[+] [-] pedrovhb|4 years ago|reply
Also have to mention the fantastic Python Prompt Toolkit, which xonsh is based on - https://python-prompt-toolkit.readthedocs.io/en/master/
I mirror another commenter's excitement on this thread about the cool libraries we have at this age, and the tools that are made possible by them.
[+] [-] MichaelMoser123|4 years ago|reply
[+] [-] mrbonner|4 years ago|reply
[+] [-] andrewshadura|4 years ago|reply
[+] [-] emehex|4 years ago|reply
...bit of a learning curve?
[+] [-] ejdyksen|4 years ago|reply
https://github.com/niedakh/pqdm
[+] [-] tdekok|4 years ago|reply
[+] [-] anonymousCar|4 years ago|reply
[+] [-] Nihilartikel|4 years ago|reply
It makes it a lot easier to casually use a database (e.g. SQLite) to persist dictionaries without explicitly building a schema.
Great for CLI apps and ad hoc data crunching.
[+] [-] 999900000999|4 years ago|reply
Yet, you can still make 200K writing it, I don't know the next time I'll create a command line application in Python, but I'll keep this little tool in mind. I hope Python eats the world.
[+] [-] MichaelMoser123|4 years ago|reply
[+] [-] pak|4 years ago|reply
https://github.com/powerpak/tqdm-ruby
(shameless plug and an invitation for pull requests)
[+] [-] QuackyTheDuck|4 years ago|reply
[+] [-] perrygeo|4 years ago|reply
[+] [-] curiousgal|4 years ago|reply
https://github.com/tqdm/tqdm.cpp
[+] [-] teddyh|4 years ago|reply
[+] [-] dwater|4 years ago|reply
[+] [-] minimaxir|4 years ago|reply
My only complaint is the smoothing parameter; by default it predicts the estimated time remaining based on the most recent updates so it can fluctuate wildly; smoothing=0 predicts based on the total runtime which makes more sense given law of large numbers.
[+] [-] drexlspivey|4 years ago|reply
[+] [-] enriquto|4 years ago|reply
Something like the NO_COLOR environement variable?
These progress bars are nice when you launched a single loop yourself, but when you are running an automated battery of many things they become annoying and pollute your terminal too much. I know that you can silence each particular program that uses tqdm by setting a 'disable' option. But this requires editing the python source code of the program.
[+] [-] zbentley|4 years ago|reply
sys.stdout.isatty() isn't a perfect answer to what people ask when they want to know "am I running in an automated environment, or is a human user looking at my output?", but it's close. More nuance is available online.
[+] [-] emehex|4 years ago|reply
[1] https://github.com/MaxHalford/chime/
[+] [-] oars|4 years ago|reply
My Python skills have improved so much thanks to HN.
[+] [-] avelis|4 years ago|reply
[+] [-] nurettin|4 years ago|reply
[+] [-] debo_|4 years ago|reply
[+] [-] tmabraham|4 years ago|reply
Another great alternative is fastprogress: https://github.com/fastai/fastprogress
It often works better in Jupyter Notebooks.
[+] [-] nvalis|4 years ago|reply
[0] https://tqdm.github.io/docs/notebook/
[+] [-] hathym|4 years ago|reply