For a more-or-less throwaway script I'm working on I need a little input function similar to Emacs's read-from-minibuffer, which accepts both a prompt and an initial string for the input buffer. Seems like I ought to be able to whip something up using readline, but it's not happening. GNU readline's docs aren't the greatest, but I thought this simple script would work: import readline readline.insert_text("default") x = raw_input("?") print x I expected to see an editable "default" displayed after the prompt and have x default to "default" if I just hit the return key. I see nothing displayed after the question mark, and x is the empty string if I just hit return. This does print "default": readline.insert_text("default") x = readline.get_line_buffer() print x so I know that insert_text and get_line_buffer seem to be working as intended. Looking at call_readline in Modules/readline.c I see nothing that would disrupt the line buffer before the call to readline(). Am I missing something totally obvious about how GNU readline works or the conditions under which readline is used (only at the interactive prompt?) or is some required bit of GNU readline not exposed through Python's readline module? Skip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4