Skip to content

Instantly share code, notes, and snippets.

@ILightThings
Created March 15, 2021 20:06
Show Gist options
  • Select an option

  • Save ILightThings/fcd7d045ce30698ffd182139e027ebe1 to your computer and use it in GitHub Desktop.

Select an option

Save ILightThings/fcd7d045ce30698ffd182139e027ebe1 to your computer and use it in GitHub Desktop.

Revisions

  1. ILightThings created this gist Mar 15, 2021.
    17 changes: 17 additions & 0 deletions Input_edit.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import readline

    def rlinput(prefill):
    readline.set_startup_hook(lambda: readline.insert_text(prefill))
    try:
    return input() # or raw_input in Python 2
    finally:
    readline.set_startup_hook()

    query = ""

    while True:
    query = rlinput(query)
    print(f"The new line is: {query}")