I'm using Python 3.2 on Ubuntu 11.10 (Linux). A piece of my new code looks like this:
text = input("TEXT=")
Is it possible to get some predefined string after the prompt, so I can adjust it if needed? It should be like this:
python3 file TEXT=thepredefinedtextishere   Now I press Backspace 3 times
TEXT=thepredefinedtextish   Now I press Enter, and the variable text should be thepredefinedtextish
Python 3 – input() function. In Python, we use input() function to take input from the user. Whatever you enter as input, the input function converts it into a string. If you enter an integer value still input() function convert it into a string.
Python provides developers with built-in functions that can be used to get input directly from users and interact with them using the command line (or shell as it is often called). In Python 2, raw_input() and in Python 3, we use input() function to take input from Command line.
Input using the input( ) function Python has an input function which lets you ask a user for some text input. You call this function to tell the program to stop and wait for the user to key in the data. In Python 2, you have a built-in function raw_input() , whereas in Python 3, you have input() .
If your Python interpreter is linked against GNU readline, input() will use it.  In this case, the following should work:
import readline  def input_with_prefill(prompt, text):     def hook():         readline.insert_text(text)         readline.redisplay()     readline.set_pre_input_hook(hook)     result = input(prompt)     readline.set_pre_input_hook()     return result 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With