curses.wrapper()

curses.wrapper(func, *args, **kwds)[source]

Wrapper function that initializes curses and calls another function, 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().