0

I am working on an application and there is a library code where it prompts the user by asking a question. The user then provides the answer in the console. The prompt and the user input are both captured using stderr. Since I cannot access the prompt from the console to the webpage, is there an easy way to perform these steps:

  1. Capture the prompt from the console inside a Python script
  2. Provide an input for the prompt from the same script as used in step 1
  3. Send the user input to the console again from the same script
enterML
  • 2,110
  • 4
  • 26
  • 38
  • Ideally you would do something like, take the user input from the actual webpage using a ```form``` and pass the relevant information to a python ```function``` and return that back to the user on the webpage. This is generally how web applications work, as far as my knowledge goes anyway. I could stand corrected. – Aidan Donnelly Oct 14 '21 at 10:51
  • @AidanDonnelly I completely agree with that. The thing is that the console thing is coming from a third part library, so I have no option to tweak the source code. That's why I asked – enterML Oct 14 '21 at 10:58
  • Do you have access to the library's source code? In that case, you might check whether there's an alternative function. Normally, one would separate user interaction with business logic, so I guess, there might be another way of achieving your goal other than relying on this somewhat hacky usage scenario. – Green绿色 Oct 14 '21 at 12:26
  • This might be of interest for you: https://stackoverflow.com/questions/14457303/python-subprocess-and-user-interaction – Green绿色 Oct 14 '21 at 12:29

0 Answers0