Re: infile and outfile parameters for the input function

On Mon, May 02, 2022 at 08:23:31PM -0700, Christopher Barker wrote:
No more of an issue than it is for other context managers, or for setting sys.stdio directly.
I feared this would happen... mea culpa. I wrote: **Long before we had context managers**, I manually redirected stdin and stdout to programmatically feed input and capture output from `raw_input`. Emphasis added. When I wrote it I feared that people wouldn't remember that "before we had context managers" was like Python 2.4 or older (by memory), and so what we call input today was called raw_input back then. So I don't need to *write* raw_input, because it already exists :-) But what I do need is a nice and reliable way to feed values into input as if they were typed by the user, and to capture the output of input. -- Steve
participants (1)
-
Steven D'Aprano