[Tutor] Interactive editing of variables.

Cameron Simpson cs at cskk.id.au
Sat Jun 1 02:45:48 EDT 2019


On 01Jun2019 12:53, Sean Murphy <mhysnm1964 at gmail.com> wrote:
>Python 3.7, windows 10.
>
>I have no clue on how to achieve what I want to do and the code I have
>creates an hash. As shown below:
>
>for row in description:
[... get some text and present it for editing ...]

>I have had a look and cannot find an example where I can interactively 
>edit a content of a variable at the command line. I do not want to use GUI at
>all. As this is a simple program only requiring CLI. I have no problems
>showing the prompt, but cannot insert text into the edit (input) area. Any
>ideas?

If I understand you, you've got your target text and you want to user to 
be given it so they can modify it, rather than having to retype it in 
full at the prompt.

On a UNIX system you'd use the standand "readline" module, and prefill 
the text buffer with your text. Is it marked as UNIX only, but I believe 
there are Windows dropins for this facility. Maybe install this package:

  https://pypi.org/project/pyreadline-ais/

maybe with "python -m pip install pyreadline-ais".

Then use it according to the documentation for the stdlib readline 
module:

  https://docs.python.org/3/library/readline.html#module-readline

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list