![](https://secure.gravatar.com/avatar/573ed3088eea742af8bcfeac90bc882d.jpg?s=120&d=mm&r=g)
Zachary Pincus wrote:
I find myself in this situation a lot: I'm looking at a sequence of plots, one for each piece of data in a collection. I usually find myself writing a loop with a plot command followed by raw_input()so that I hit enter in the terminal window IPython session to move to the next item. I usually make this conditional so that I can process in batch without looking at the plots if I choose.
This has the effect of producing a newline in the terminal every time I want to move on to the next plot, which is far from ideal, especially in the situation where I'm not printing anything else in that window.
Old-school alternative is to put the TTY into cbreak (aka "rare" mode, between "raw" and "cooked"), and capture a single key-hit. (Except that ^C still breaks, which is handy.) For windows, the C runtime has a similar getkey function.
Here's windows / posix code for that that I've assembled from various snippets online; note that the latter uses the well-known decorator module. I've also included an "iskeydown" function which I find useful in various situations...
I have collected some useful snippets to do a similar thing too - now I merged the functionality, added some sugar (pause functions), stirred and cooked - see the attachment. $ python getch.py Are you ok with me using it in my (BSD) project? thanks, r.