5 ms·
Rich is probably the biggest lifestyle change I've ever had because of a single library. Every one of my scripts now has quick and easy progress bars, console
by danudey 5y ago
Rich is probably the biggest lifestyle change I've ever had because of a single library.
Every one of my scripts now has quick and easy progress bars, console management (including saving a copy of console output), tables with columns, rows, and headers, "Processing..." blocks, colours, error logging, emoji, and on and on and on. It's really an amazing project that does a ton of stuff and makes it all easy to do.
If nothing else, add "from rich import print" to the top of your script (assuming you use print() statements) and see how your output looks afterwards, with highlighted numbers/floats, IP addresses, etc., formatted and syntax-highlighted JSON and repr output, and so on.
- bikingbismuth 5y agoThanks for the suggestion. I occasionally add progress % to some of my scripts, but anything more advanced I can’t be bothered. Excited to check out the library, thanks for the print() suggestion.
- jszymborski 5y agoI so appreciate the little things, like `console.log` printing not only discretely naming the filename and line, but also providing a link to it.
- danudey 5y agoOr the logging output only outputting timestamps when they're different so you can clearly see what happens and when.
- TylerE 5y agoQuestion: How horribly does the world break if you pipe the output to a file instead of stdout?
- eyegor 5y agoI would assume the lib authors accounted for this, it's pretty easy to check with sys.stdout.isatty(). If not you could alias it yourself.
- deleted 5y ago[deleted]
- windexh8er 5y agoRich McGugan (author of Rich) talks about a lot of different design aspects of Rich on an episode of Talk Python [0] last October. I've used it in a few projects since then and for what I've been using it for the output is still easily consumable. Rich is a game changer for output in Python and it pairs nicely with CLI libs like Click. McGugan also is putting a lot of effort into Textual [1] which is fantastic for TUI apps. [0] https://talkpython.fm/episodes/show/336/terminal-magic-with-rich-and-textual https://talkpython.fm/episodes/show/336/terminal-magic-with-... [1] https://github.com/Textualize/textual https://github.com/Textualize/textual
- willm 5y ago*Will McGugan :)
- windexh8er 5y agoOh man, fail on my part. Apologies Will! I think now's a great time for me to donate. ¯\_(ツ)_/¯ Edit: Tried to sponsor your linked Ko-fi from what's listed in the rich repo, but the link provided doesn't work and searching your name doesn't pull anything up. Sent you an email to find a better way.
- varenc 5y agoNot at all! Like many CLI tools, it turns off the formatting when it detects you're not outputting to a terminal. Here's where it checks: https://github.com/Textualize/rich/blob/5a457bfbc662ab8701dcb71080d0b9bbdb2b8b72/rich/console.py#L904 https://github.com/Textualize/rich/blob/5a457bfbc662ab8701dc... (and I just tested to confirm it does indeed work)
- willm 5y agoGlad you find it useful!