homepage

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 <1374553476.03.0.407785357312.issue15805@psf.upfronthosting.co.za>
In-reply-to
Content
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(...):
 write_xyz()
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: 
@contextlib.contextmanager
def redirect_stdout(stream):
 old_stdout = sys.stdout
 sys.stdout = stream
 yield
 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.
History
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: <1374553476.03.0.407785357312.issue15805@psf.upfronthosting.co.za>
2013年07月23日 04:24:36belopolskylinkissue15805 messages
2013年07月23日 04:24:35belopolskycreate

AltStyle によって変換されたページ (->オリジナル) /