Author wt
Recipients wt
Date 2017-09-27.06:34:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1506494047.11.0.154975027568.issue31603@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2017-09-27 06:34:07wtsetrecipients: + wt
2017-09-27 06:34:07wtsetmessageid: <1506494047.11.0.154975027568.issue31603@psf.upfronthosting.co.za>
2017-09-27 06:34:07wtlinkissue31603 messages
2017-09-27 06:34:06wtcreate