Message303103
I would really love to add a few params to input so that it's signature looked more like so:
def input(prompt, /, *, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr):
...
This would certainly make overriding the the files in specific calls to input easier. A reasonable use case is collecting a piece over /dev/tty explicitly so that a redirected stdin could be used to pipe data into a program while overriding using /dev/tty to collect some piece of data. Here's some code illustrating what I'd like:
import sys
sys.stdin.close()
sys.stdin = open('/dev/null', 'r')
with open('/dev/tty', 'r') as f:
x = input('Name? ', fin=f)
print(x)
FWIW, I have actually already implemented this fully (including tests). I am just trying to see what I need to do to allow release since I am work on my employer's time.
In the interest of getting feedback, does the signature provided above look sane? |
|
Date |
User |
Action |
Args |
2017-09-27 06:34:07 | wt | set | recipients:
+ wt |
2017-09-27 06:34:07 | wt | set | messageid: <1506494047.11.0.154975027568.issue31603@psf.upfronthosting.co.za> |
2017-09-27 06:34:07 | wt | link | issue31603 messages |
2017-09-27 06:34:06 | wt | create | |
|