The :func:`~curses.wrapper` function takes a callable object and does the initializations described above, also initializing colors if color support is present.:func:`!wrapper` then runs your provided callable. Once the callable returns, :func:`!wrapper` will restore the original state of the terminal.The callable is called inside a :keyword:`try`...\ :keyword:`except` that catches exceptions, restores the state of the terminal, and then re-raises the exception.Therefore your terminal won't be left in a funny state on exception and you'll be able to read the exception's message and traceback.