code: def get_columns (fp):
      
      if not is_tty(fp):
          return 80
      if os.name == 'nt':
          return colorama.get_console_size().X
      if has_curses:
          import curses
          try:
              curses.setupterm(os.environ.get("TERM"), fp.fileno())
              return curses.tigetnum("cols")
          except curses.error:
             pass
      return 80
docs: Return number of columns for given file.