29 Sep
2017
29 Sep
'17
7:19 a.m.
29.09.17 14:40, Steven D'Aprano пише:
Because the two-liner doesn't do what input() does. Testing it at the interactive interpreter gives me:
py> def myinput(): .... sys.stdout.write("Name? ") .... return sys.stdin.readline() .... py> x = myinput() Steve py> ? py>
The output isn't displayed until the input is entered, and then the prompt messes it up.
Well, I forgot about a flush(). Now this is just a three-liner. fout.write('Name? ') fout.flush() name = fin.readline()
There's no support for arrow keys, even when readline is available:
My name^[[D^[[C^[[D
Did you check that arrow keys are supported with the proposed PR?