On 01/06/2019 03:53, mhysnm1...@gmail.com wrote:

> I have no clue on how to achieve what I want to do and the code I have
> creates an hash. As shown below:

Thats because what you want is not a standard feature of CLI apps.
You will need to do one of the following(in order of easiness):
1) Use a GUI - it then becomes a trivial matter
2) Use a pseudo GUI like curses to provide cursor control
3) Find a module that already does what you need
   (maybe readline can be made to work?)
4) Write a function yourself using screen primitives
   that manage the cursor


> for row in description:
>     text = description_rejex(row)
>     if text[0] not in narration: 
>         Result = input(text[0])
>         narration[result] = text

The standard tools allow you to input a new value and overwrite
the existing one. But there is no simple way to interactively
modify an existing value (and of course you would need to
convert it to/from a string for that to be possible)

> 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. 

A GUI makes this a trivial problem. Simply display an edit control and
insert the current value as a string. Allow the user to modify it and
when done read the new value back. If you don't want to use a GUI you
need to provide GUI like controls yourself, either through an existing
module or by writing one. Something like easygui would be eminently
suitable. But even vanilla Tkinter is almost trivial.

The curses library will do it but that is not standard on Windows
and I've heard varying reports of how well it works there.

The readline library allows basic editing of the commands line but I'm
not sure how you would insert your variable into the command line
initially...

For windows there are a couple of modules available that provide low
level cursor control and character input/output, so you could use one of
those to write such a function.

And if you search hard enough you should find that somebody, somewhere
has already done the work for you. But I don't know where...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to