{"id":3892,"library":"autopage","title":"autopage","description":"Autopage is a Python library designed to automatically display terminal output from a program in a pager (like `less`) when the output is extensive, and behave normally otherwise. It ensures consistent, user-friendly console output, preserves colors, and correctly handles output redirection. The current version is 0.6.0, released on January 29, 2026. While there isn't a strict stated release cadence, releases tend to be infrequent, occurring roughly every 6-18 months.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/zaneb/autopage","tags":["console","CLI","pager","output","utility"],"install":[{"cmd":"pip install autopage","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"AutoPager","correct":"from autopage import AutoPager"},{"note":"Used to automatically page help output for `argparse` based CLIs. Can also be used as a context manager.","symbol":"monkey_patch (for argparse)","correct":"import autopage.argparse\nautopage.argparse.monkey_patch()"}],"quickstart":{"code":"import sys\nimport autopage\n\n# Function to generate lines of text\ndef generate_lines(num_lines):\n    for i in range(1, num_lines + 1):\n        yield f\"This is line {i} of the generated output. \" * 5 + \"\\n\"\n\nif __name__ == \"__main__\":\n    print(\"--- Output without autopage (might scroll rapidly) ---\")\n    for line in generate_lines(20): # Generate a few lines\n        sys.stdout.write(line)\n    print(\"--- End without autopage ---\\n\")\n\n    print(\"--- Output with autopage (will use a pager like 'less' if output exceeds screen) ---\")\n    try:\n        with autopage.AutoPager() as out:\n            for line in generate_lines(100): # Generate many lines to trigger the pager\n                out.write(line)\n    except Exception as e:\n        print(f\"An error occurred with autopage: {e}\")\n        print(\"Ensure a pager like 'less' is installed and available in your PATH.\")\n    print(\"--- End with autopage ---\\n\")\n","lang":"python","description":"This quickstart demonstrates how to use `autopage.AutoPager` as a context manager to pipe extensive console output through a system pager (like `less`). It generates a large amount of text, first printing it directly to `stdout` and then routing it through `AutoPager` to show the difference. For `autopage` to function, a pager (e.g., `less`) must be installed and accessible in the system's PATH."},"warnings":[{"fix":"Ensure you are importing `from autopage import AutoPager` and not attempting to use web scraping functionality.","message":"Do not confuse `autopage` (for console output paging) with `autopager` (a different library for detecting web pagination links). They serve entirely different purposes and have different APIs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pass `line_buffering=True` to the `AutoPager` constructor (e.g., `with autopage.AutoPager(line_buffering=True) as out:`) to force line buffering.","message":"The default line buffering behavior of `AutoPager` matches the underlying stream's setting. If the output stream is not line-buffered (common when piping output to another command or file), you might experience delayed or incomplete output.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pass `reset_on_exit=True` to the `AutoPager` constructor (e.g., `with autopage.AutoPager(reset_on_exit=True) as out:`).","message":"By default, `AutoPager` leaves the latest displayed output on screen when the pager exits. If you prefer the terminal to clear and return to its state before the pager started (mimicking the default behavior of `less` when exited), you need to explicitly configure this.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}