Previously raised here [1], contextlib.redirect_stdio would be a utility 
function to help redirect standard input, output and error. The idea of a 
function called "stdio" that does the same thing was also raised. The function 
would combine the functionality of contextlib.redirect_stdout and 
contextlib.redirect_stderr which work as described in the documentation [2].

It would also add "contextlib.redirect_stdin" functionality which currently 
appears to be missing.

The usage described in the original python-ideas post looks like this:

> There's already contextlib.redirect_stdout() and
> contextlib.redirect_stderr(). Adding contextlib.redirect_stdin() would
> be logical, but I think a more flexible
> 
>     contextlib.redirect_stdio(stdin=None, stdout=None, stderr=None)
>
> would be better - where None (the default) means "leave this alone".

I'm interested to hear what people think about this.

Kind regards,
Sam Ezeh

[1]: https://mail.python.org/pipermail/python-ideas/2017-September/047236.html
[2]: 
https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout
_______________________________________________
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/OMLVJ5RI3C62PERTFADLAVMEEMOI6PF4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to