Python3 curses behavior

Terry Reedy tjreedy at
Sat Feb 9 20:22:47 CET 2013

On 2/9/2013 6:23 AM, Vlasov Vitaly wrote:
> Hello.
> I found strange behavior of curses module, that i can't understand. I
> initialize screen with curses.initscr(), then i create subwin of
> screen with screen.subwin(my_subwin_sizes). After that i fill subwin
> with my_char in for-loop. On last char in last line subwin.addch()
> raises exception.

I have never used curses but I have used text screens. I suspect that 
addch moves the cursor to the position beyond where the character is 
added, but there is no such position. I remember having problems writing 
to the last char of a 24x80 screen without getting either a scroll or 
beep if scrolling was disabled.

> This is my problem. Why? How to fix it?

Perhaps this will help:
If yes is 1, cursor is left where it is on update, instead of being at 
“cursor position.” This reduces cursor movement where possible. If 
possible the cursor will be made invisible.

> (If i will ignore exception, then last char will be displayed)

Otherwise, just catch the exception, as you already discovered.

> Here simple example:

Terry Jan Reedy

More information about the Python-list mailing list