Nikolaus Rath added the comment:

I think stdout redirection is very useful, and I'm actually have a very similar 
context manager in my own code.

However, I'd like to raise the question if using a context manager for this 
purpose should really be "officially blessed" in this way.

To me, the with statement signals that effects are constrained to the managed 
block. But redirecting sys.stdout is a change with global scope - the 
redirection is not restricted to execution of the with block, it affects every 
other thread that's running at the same time. This effect is obvious if you 
wrote the redirection context manager yourself, but if you're using code from 
the standard library, this may be surprising.

I don't have a better proposal, but I just wanted to mention this...

----------
nosy: +Nikratio

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15805>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to