views:

31

answers:

1

I'm already aware of using \b and \r to move back one character and to the beginning on the line respectively. But is there a way, (specifically in python,) to move the cursor position up 1 line? I'm trying to avoid using curses, but if this is the best option then so be it.

+1  A: 

The cuu1 capability will give you the sequence you need in order to do so.

echo -e "aa\n$(tput cuu1)b"
Ignacio Vazquez-Abrams
Interesting, but I was honestly hoping to accomplish this without calling an external program. If nothing better comes along I'll do this though!
OmnipotentEntity
`curses.tigetstr('cuu1')`
Ignacio Vazquez-Abrams
I assume that I'll need to use curses then and there's no getting around it... :)
OmnipotentEntity
@OmnipotentEntity: It's not recommended that you hardcode terminal control sequences, but this may be of interest to you: Of the over 1500 terminfo terminal description files on my system, over 700 use `Esc[A` for `cuu1`, 230 use VT (`0x0B`), 181 don't have it, and 176 use `EscA`. The others use over 30 other sequences.
Dennis Williamson