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 belopolsky
Recipients Marc.Abramowitz, alex, barry, belopolsky, ezio.melotti, ncoghlan, nikratio, pitrou, rhettinger, vstinner
Date 2013-07-23.04:24:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Yes, I did miss Victor's dup2() comment.  (It looks like I did not subscribe to this issue from the start and missed early discussion - sorry.)

The simple feature is not very useful for me.  I have to deal with too many cases of misguided code like this:

def write_xyz(output=sys.stdout):

for which 

with RedirectStdout(...):

will not work.

I will create a separate issue once I have a concrete proposal, but with respect to this specific issue, I think it is better to provide a recipe in contextlib documentation for something like this: 

def redirect_stdout(stream):
    old_stdout = sys.stdout
    sys.stdout = stream
    sys.stdout = old_stdout

With the proposed RedirectStdout, I think many users will want some tweaks and will copy the "from scratch" implementation instead of discovering contextmanager.
Date User Action Args
2013-07-23 04:24:36belopolskysetrecipients: + belopolsky, barry, rhettinger, ncoghlan, pitrou, vstinner, ezio.melotti, alex, nikratio, Marc.Abramowitz
2013-07-23 04:24:36belopolskysetmessageid: <>
2013-07-23 04:24:36belopolskylinkissue15805 messages
2013-07-23 04:24:35belopolskycreate