{"id":1662,"library":"pyreadline3","title":"pyreadline3: GNU Readline for Python on Windows","description":"pyreadline3 is a Python implementation of GNU readline functionality, primarily designed for Windows environments where the native `readline` module is not available. It is a continuation of the `pyreadline` package, providing features like command history, tab completion, and keyboard shortcuts. Version 3.4+ of pyreadline3 supports Python 3.8+ and is actively maintained.","status":"active","version":"3.5.4","language":"en","source_language":"en","source_url":"https://github.com/pyreadline3/pyreadline3.git","tags":["readline","windows","cli","console","history","tab-completion","interactive"],"install":[{"cmd":"pip install pyreadline3","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"On Windows, pyreadline3 typically patches the built-in 'readline' module, making it available as if it were the standard Unix 'readline' library.","symbol":"readline","correct":"import readline"},{"note":"Directly import the Readline class for explicit control or when the implicit patching of the 'readline' module is not desired or working as expected.","symbol":"Readline","correct":"from pyreadline3 import Readline"}],"quickstart":{"code":"import sys\n# On Windows, pyreadline3 often patches sys.modules['readline']\n# so standard 'import readline' works. Explicit import is also possible.\ntry:\n    import readline\nexcept ImportError:\n    from pyreadline3 import Readline\n    readline = Readline()\n\nprint(\"pyreadline3 is active. Try typing, using arrow keys for history, or Tab (if configured).\")\nprint(\"Enter 'exit' to quit.\")\n\nwhile True:\n    try:\n        user_input = input(\">>> \")\n        if user_input.lower() == 'exit':\n            break\n        if user_input:\n            print(f\"You typed: {user_input}\")\n    except EOFError: # Ctrl+D\n        print(\"\\nExiting (Ctrl+D detected).\")\n        break\n    except KeyboardInterrupt: # Ctrl+C\n        print(\"\\nExiting (Ctrl+C detected).\")\n        break","lang":"python","description":"This quickstart demonstrates how pyreadline3 makes the `readline` module available and functional on Windows. After installation, `import readline` should seamlessly provide command-line editing features. The example shows a basic interactive loop with exit conditions."},"warnings":[{"fix":"Use Python versions prior to 3.13 or monitor the pyreadline3 GitHub repository for updates and compatibility fixes for Python 3.13+.","message":"pyreadline3 currently does not work with Python 3.13.0, as Python 3.13 introduced a new REPL. Even with `PYTHON_BASIC_REPL` environment variable set, history is not preserved across sessions.","severity":"breaking","affected_versions":"3.x.x with Python >= 3.13"},{"fix":"Ensure the history file is created (e.g., `open(filename, 'w').close()`) before attempting to read from it.","message":"When managing history files with `readline.read_history_file()`, the specified history file must already exist. If it does not, a `FileNotFoundError` will be raised.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Confirm you need `pyreadline3` for your specific operating system. On Unix-like systems, the built-in `readline` module is usually sufficient.","message":"pyreadline3 is primarily developed and tested for Windows environments to provide GNU readline functionality where it's natively absent. While it may technically install on other OS, its primary benefit is on Windows, and behavior on Unix-like systems (which have a native `readline` module) might be unexpected or redundant.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Configure `allow_ctrl_c(True)` and adjust `ctrl_c_tap_time_interval(x)` in a configuration file (`pyreadlineconfig.ini`) or through `parse_and_bind` to customize Ctrl-C behavior.","message":"The Ctrl-C key binding has configurable behavior. By default, it might act as a copy operation, requiring a double-tap within a configurable time interval (`ctrl_c_tap_time_interval`) to raise a `KeyboardInterrupt`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}