Message193583
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. |
|
Date |
User |
Action |
Args |
2013-07-23 04:24:36 | belopolsky | set | recipients:
+ belopolsky, barry, rhettinger, ncoghlan, pitrou, vstinner, ezio.melotti, alex, nikratio, Marc.Abramowitz |
2013-07-23 04:24:36 | belopolsky | set | messageid: <1374553476.03.0.407785357312.issue15805@psf.upfronthosting.co.za> |
2013-07-23 04:24:36 | belopolsky | link | issue15805 messages |
2013-07-23 04:24:35 | belopolsky | create | |
|