code: def terminal_size():  # decide on *some* terminal size
      
      cr = _ioctl_GWINSZ(0) or _ioctl_GWINSZ(
          1) or _ioctl_GWINSZ(2)  # try open fds
      if not cr:                                                  # ...then ctty
          try:
              fd = os.open(os.ctermid(), os.O_RDONLY)
              cr = _ioctl_GWINSZ(fd)
              os.close(fd)
          except BaseException:
              pass
          if not cr:                            # env vars or finally defaults
              try:
                  cr = os.environ['LINES'], os.environ['COLUMNS']
              except BaseException:
                  cr = 25, 80
      return int(cr[1]), int(cr[0])
docs: Return (lines, columns).