29.09.17 08:53, Wren Turkal пише:
This is meant to turn code like the following:
orig_stdin = sys.stdin
orig_stdout = sys.stdout
with open('/dev/tty', 'r+') as f:
sys.stdin = f
sys.stdout = f
name = input('Name? ')
sys.stdin = orig_stdin
sys.stdout = orig_stdout
print(name)
into something more like this:
with open('/dev/tty', 'r+') as f:
name = input('Name? ', fin=f, fout=f)
print(name)
Why not use just the following two lines?
f.write('Name? ')
name = f.readline()
This falls to me in the category "not every two lines of the code should
be added as a builtin".
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/