Conversation
This does not work.
There was a problem hiding this comment.
Pull request overview
This PR attempts to enhance the user experience of interactive input prompts by importing Python's readline module, which provides line editing and command history capabilities. However, as noted in the PR description, the implementation doesn't work as intended. The change adds documentation explaining the intent and imports the readline module in the noweb literate programming structure.
Key changes:
- Adds documentation explaining the intent to use GNU readline for improved input usability
- Imports the
readlinemodule via a<<imports>>=code chunk
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| For the above input methods, we want improved usability, so we will use the GNU | ||
| readline version of input. | ||
| <<imports>>= | ||
| import readline |
There was a problem hiding this comment.
The readline import should be wrapped in a try-except block to handle platforms where it's not available (e.g., Windows). The module will fail to import on systems without GNU readline support.
Suggested fix:
try:
import readline
except ImportError:
pass # readline not available, input() will work without enhanced featuresThis approach is the standard Python pattern for optional readline support.
| import readline | |
| try: | |
| import readline | |
| except ImportError: | |
| pass # readline not available, input() will work without enhanced features |
| For the above input methods, we want improved usability, so we will use the GNU | ||
| readline version of input. |
There was a problem hiding this comment.
The documentation is misleading. Python's readline module doesn't provide a separate "readline version of input" - it automatically enhances the built-in input() function when imported. The comment should clarify this behavior.
Suggested rewording:
For the above input methods, we want improved usability. By importing the
readline module, the built-in input() function is automatically enhanced with
line editing capabilities and command history (when available).
| For the above input methods, we want improved usability, so we will use the GNU | |
| readline version of input. | |
| For the above input methods, we want improved usability. By importing the | |
| readline module, the built-in input() function is automatically enhanced with | |
| line editing capabilities and command history (when available). |
This does not work.