2

I'm wondering if there's a way to make user edit some input.
I have tried:

sys.stdin.write("Foo bar")
input()

And expected this behaviour:

<< Foo bar

The user will edit the string "Foo bar" (e.g. "Foo bar baz"), press enter and the input should return the edited string (e.b. "Foo bar baz").

It's something like "editable prompt".

Is there a way to do it?

EDIT: I'm running on OS X, but I would like to support other platforms too.

R.O.S.S
  • 605
  • 5
  • 18
  • @Slayer OP wants something different - to be able to actually present a prompt that can be edited, rather than get a default value from the user. – Akshat Mahajan Apr 15 '16 at 19:17
  • Functions like `input()` or `raw_input()` block (don't let other code run) until they finish, so you can't write to the stream programmatically at the same time as other functions. You want [nonblocking console input](http://stackoverflow.com/questions/2408560/python-nonblocking-console-input) that lets you suspend, write to console, and then have user do something with that write. If you can provide specifics about the platform, we can probably help more. – Akshat Mahajan Apr 15 '16 at 19:25

0 Answers0