old_contents: import curses
  
  
  def init_curses():
      screen = curses.initscr()
      curses.noecho()
      curses.cbreak()
      screen.keypad(True)
      return screen
  
  
  def quit_curses(screen):
      curses.nocbreak()
      screen.keypad(False)
      curses.echo()
      curses.endwin()
  
  
  def main():
      screen = init_curses()
      quit_curses(screen)
  
  
  if __name__ == '__main__':
      main()
  
  
new_contents: import curses
  
  
  def main(screen):
      print('In main')
      screen.clear()
      screen.refresh()
  
  
  if __name__ == '__main__':
      curses.wrapper(main)
  
  
subject: Use curses.wrapper instead