Hacker News new | past | comments | ask | show | jobs | submit login
Blessings: a pythonic answer to curses (python.org)
125 points by whit537 on Aug 17, 2012 | hide | past | web | favorite | 23 comments



So glad you're enjoying Blessings! I've had fun writing it.

I'd love to hear what kind of projects other folks are doing with it. Any neat hacks? One of my fun little demos is this terminal-dwelling Game of Life: http://pypi.python.org/pypi/conway/. I was thinking of adding an interactive mode so you can draw your own patterns and set them free; it would be an excuse to add key trapping to Blessings.


Oh, and for any who like the look of Blessings but don't have any terminal projects afoot, shoppers who looked at this item also viewed...

A sequel to itertools: http://pypi.python.org/pypi/more-itertools/ (The upcoming 2.1 will include all the routines from the "recipes" section of the docs as well.)

A front end for the popular Nose test runner that shows a progress bar and tracebacks during tests (via blessings, of course): http://pypi.python.org/pypi/nose-progressive/

A shim for using Nose with Django (and making your tests go 4x as fast): http://pypi.python.org/pypi/django-nose/

While on the subject of Django, here's a little shim to let you write lightweight management subcommands (and generate commands at runtime, if you want to go crazy): http://pypi.python.org/pypi/django-subcommander/


Not only does this seem like an excellent replacement for curses, this overview/readme is a really great example of exactly how to detail a library/component's capabilities and how to use them. I've bookmarked this to use as a reference when writing my own documentation.


I recently had the terrible idea of writing a new screen editor. This project is very much not helping me avoid working on that idea.


What makes you want to do that - can I assume that it means you can't find an editor which works the way you need it to?


Not exactly. I've been using Emacs for years and am idly learning Vim. There are just some UI and interaction ideas I wanted to try out.


Must be a forth programmer.

Those people are the unabombers of programming.

Weird, isolated, and unhappy with everything.


I felt the same way in the past, and I am not a Forth programmer... nor do I have a manifesto or a bomb shack


Leave more than one screenful of scrollback in the buffer after your program exits, like a well-behaved command-line app should.

If you hate this, you can tweak your terminal definition so curses apps don't do it. http://fixlog.blogspot.com.au/2006/09/stop-gnome-terminal-sc...


> Blessings provides just one top-level object: Terminal. Instantiating a Terminal figures out whether you're on a terminal at all and, if so, does any necessary terminal setup.

Why doesn't the module figure this out at import? Since there is a single terminal (at least right now), I don't see the point of having to instantiate a class. All that stuff could be provided directly by the module. Or if there's the possibility of controlling 2 terminals simultaneously, do something similar with the random module. Provide both functions and a class that can be instantiated if needed.


Deferring the setup is first a matter of politeness, an artifact of my opinion that importing a module shouldn't have (possibly surprising) side effects on the environment.

As for hanging everything off the Terminal instance, the motivation is that there's significant state on it that you might want to customize. Things like type (ANSI, vt100, etc.) and whether to suppress or force styling affect the result of formatting methods. See http://packages.python.org/blessings/#blessings.Terminal.__i.... I've several times benefitted by making a formatting-suppressed Terminal and passing it around.

I fully endorse you saying...

    term = Terminal()
...at the top level of some module and referencing it there. Then you get the init-on-import behavior you want, but it's not forced on anybody who'd rather not have it.

Cheers!


Or as The Zen of Pythons says, explicit is better than implicit. Thanks for clearing things up for me.


Looking forward to try this out for a terminal based streaming-data feed rendering library for columnar data. The curses module in python has been ... interesting ... so any alternative is welcome.


I just experimented a bit with Blessings and I love it! I have used some urwid for terminal projects, but for the next one I'll consider Blessings as well.

Also I can't believe how few lines of code it is...


This is amazing serendipity. I was literally just then reading through python's curses docs when this post came through.

Blessings will make my task a piece of cake. Thanks!


After having difficulty trying to write a console application with python/curses, this looks a much nicer way of doing it.


I work with curses a LOT for fun server utilities on our big-screen monitor at work. Super excited to give this a go.


At a glance, this looks so very awesome. I've definitely wanted something like this a number of time now!


We have been using termcolor for getting formatted output. This seems much more powerful and intuitive.


I'd love to have something like this for Ruby. Does anyone know a decent ruby [n]curses wrapper?


My friend keeps track of such things: https://www.google.com/search?q=ruby+ncurses


this is great. i always felt that the most common webpages we visit would be great if they were to be rendered in terminal in text only; hackernews,reddit,news,mail etc.


Callable strings? Only in Python (oh how I love thee).




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: