On Mon, May 02, 2022 at 08:23:31PM -0700, Christopher Barker wrote:
> On Mon, May 2, 2022 at 11:18 AM Steven D'Aprano
> 
> > why one couldn't just use the redirect_stdout context manager.
> >
> > (Plus not-yet-existing, but hopefully soon, redirect_stdin.)
> 
> 
> I have no use for this but thread safety could be an issue.

No more of an issue than it is for other context managers, or for 
setting sys.stdio directly.

> I have no idea if that’s an issue for the kinds of programs this might be
> used in, but always good to keep in mind.
> 
> Also — is it that hard to write raw_input()?

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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/R6DTLF7G2PCZJV7BAO2GYQMM66C4AFDF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to