Python Forum
Modify Input() text - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Modify Input() text (/thread-27493.html)



Modify Input() text - catosp - Jun-08-2020

Hello!
strText = "this is text 1"
a = input()+strText #or something like this
print(a)
How can I make to appear strText as input text that can be modified? What I want is to modify some text in strText but i don't want to write the entire string from the beggining, i want to appear automatically the strText and to modify only some text inside.

I hope that you can understand me!
Thank you!


RE: Modify Input() text - Gribouillis - Jun-08-2020

catosp Wrote:I hope that you can understand me!
Sorry, I cannot. Please explain what you want to do. For example suppose that the user enters "spam". What effect do you expect from your code?


RE: Modify Input() text - catosp - Jun-08-2020

I want to use strText as predefined input text which can be modified from keyboard before hit enter and to pass it to variable a.


RE: Modify Input() text - Yoriz - Jun-08-2020

Maybe something like
strText = "this is text 1"
a = ', '.join((input('input something '), strText))
print(a)
Output:
input something something something, this is text 1



RE: Modify Input() text - catosp - Jun-08-2020

@Yoriz. Not exactly!
Let suppose that you want to write from keyboard in console for the input() the following text: I love hamburger. But you dont want to write the same string again and again, sometimes you want to write:I hate hamburger. In that case instead of write I hate hamburger from keyboard, you want to appear in console the text I love hamburger, and navigate with your keyboard arrow to word love and delete it with backspace and replace it with the word hate.

Something like when you hit up arrow on cmd and call the last command, but instead of last command I want a specific predefined string, but which can be modified.


RE: Modify Input() text - Yoriz - Jun-08-2020

Sound like you would be better off using a GUI with a text entry which can be pre-filled with anything you like.


RE: Modify Input() text - deanhystad - Jun-08-2020

I think catosp is talking about something like command line retrieval that is supported by almost every command shell. And I have the ability to recall previous things I typed into a python script if I started that script from a shell. For example I rand a program from the Windows CMD shell:
Output:
C:\musings>python echo.py type something: I typed this I typed this type something: I typed this and used up arrow to recall "I typed this" I typed this and used up arrow to recall "I typed this"
If you are running a program from IDLE you can access the "input" history by typing alt+p. For other terminals in other IDE's I imagine there are similar ways to reduce typing.