389
82
pedrovhb
An extremely useful hidden gem in Rich is its `inspect` function [1].

When called on an object, it pretty prints a list of its public attributes (though you can also request private and dunder attributes) [2]. It can also be called on a class or function; it'll then pretty print the docstrings, parameters with types, methods, etc. It's great for debugging and for starting to code with libraries you're not familiar with, don't have comprehensive documentation, or have some dynamic aspect.

In a similar vein, `objexplore` [3] is another library that lets you dive into an object's nested attributes to understand how it's laid out.

In interactive debugging sessions I often find these to be more useful than the IDE's features which provide similar functionality.

[1] https://rich.readthedocs.io/en/stable/reference/init.html#ri...

[2] https://i2.paste.pics/798cff2903f6b3351289a24c839d4f44.png

[3] https://github.com/kylepollina/objexplore

bitigchi
I am not sure if it's only me, but as time passes I find myself using more and more simple Terminal stuff. No fancy air/earth lines, no fancy formatting, no fancy ligatures or typefaces.
samwillis
See also Textual by the same developer. Really impressive work.

https://github.com/Textualize/textual

asicsp
Past discussion:

Show HN: Python lib for rich text, markdown, tables, etc. in the terminal (https://news.ycombinator.com/item?id=23070821 2020, 47 comments)

Related discussion:

Textual: a Python text user interface with Rich as the renderer (https://news.ycombinator.com/item?id=27526031 7 months ago, 21 comments)

dayjah
The way structlog and rich work together makes for a really great and simple development experience;

Stack traces are presented in a gorgeous fashion, log.debug lines have lots of great meta data with them. I almost always start new projects with those as my first imports.

noufalibrahim
I've been following Will McGugan (the author) on twitter for a while. I learnt PyGame from his book. He more or less documented his thought processes on twitter and it's been very nice to see it develop over time.

It got me thinking that, atleast for technology developers, this is the ideal use of twitter. An uncensored "thoughtstream". Some tools to mine that and extract lessons might be an interesting project.

nyellin
Very nice. Two other great python libraries for cli display are:

1 tabulate: helps render ASCII tables in various formats (https://github.com/astanin/python-tabulate)

2. typer: write cli commands by decorating python functions. It uses type annotations to automatically parse input (https://typer.tiangolo.com/)

We're using both of those in our Kubernetes troubleshooting tool (https://robusta.dev). Going to look at adding Rich too

ZeroGravitas
Is there a companion project for the input side of these apps, like a modernized readline type thing yet?
iqanq
I hate CLI utilities that think they are so cool for turning my terminal into a disco.
rajandatta
The library looks brilliant! The author's clearly put a lot of thought and effort into it. Looking forward to using it.
armchairhacker
Great library and an amazing README. I kind of wish this functionality was built into the language tooling and other languages.
asimjalis
I especially like pretty print in rich. Makes it so much fun to introspect on deeply nested objects and JSON.
rjzzleep
This looks interesting. Can anyone explain to me why cli rich text editors seemingly died after DOS?
jack_pp
Anyone know what font he's using for the screenshots?
zashackernews
It's Atreides and Hawat not Atriedies and Haway
jmakov
Having logging integrated would be awesome.
comonoid
It seems Rich is not compatible with communism.