6.15 curses.wrapper -- Terminal handler for curses programs

New in version 1.6.

This module supplies one function, wrapper(), which runs another function which should be the rest of your curses-using application. If the application raises an exception, wrapper() will restore the terminal to a sane state before passing it further up the stack and generating a traceback.

wrapper(func, ...)
Wrapper function that initializes curses and calls another function, func, restoring normal keyboard/screen behavior on error. The callable object func is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper().

Before calling the hook function, wrapper() turns on cbreak mode, turns off echo, enables the terminal keypad, and initializes colors if the terminal has color support. On exit (whether normally or by exception) it restores cooked mode, turns on echo, and disables the terminal keypad.

See About this document... for information on suggesting changes.