This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients Marc.Abramowitz, alex, barry, belopolsky, brett.cannon, ezio.melotti, ncoghlan, nikratio, pitrou, rhettinger, vstinner
Date 2013-07-22.14:14:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
In general, I like where this is going.  I agree that a stdout redirector is
probably the most common case, and for that, it almost always (for me)
redirects to an open file.  The use case for stderr redirection is usually,
but not always, to redirect stderr to stdout, but I agree that that is much
more limited.  stdin redirection is much more rare, mostly a testing device,
and better done with mocking.

A suggestion about the name.  Thinking about how it will read in a

    with stdout_to(some_file):

Since this is all about convenience, I'd mildly suggest an API similar to
built-in open().  I'd rather write this:

    with stdout_to('/tmp/debug.log', 'w', encoding='utf-8'):

than this:

    with open('/tmp/debug.log', 'w', encoding='utf-8') as tmp_stdout:
        with stdout_to(tmp_stdout):

stdout_to() could optionally take a single which would be an already open file

Anyway, no doubt you'll paint this bikeshed your own particular color.  Mine
only cost $0.02.
Date User Action Args
2013-07-22 14:14:23barrysetrecipients: + barry, brett.cannon, rhettinger, ncoghlan, belopolsky, pitrou, vstinner, ezio.melotti, alex, nikratio, Marc.Abramowitz
2013-07-22 14:14:23barrylinkissue15805 messages
2013-07-22 14:14:23barrycreate