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?

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to