Message193599
| Author |
barry |
| Recipients |
Marc.Abramowitz, alex, barry, belopolsky, ezio.melotti, ncoghlan, nikratio, pitrou, rhettinger, vstinner |
| Date |
2013年07月23日.12:53:35 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<20130723085332.092ff7ec@anarchist> |
| In-reply-to |
<1374553476.03.0.407785357312.issue15805@psf.upfronthosting.co.za> |
| Content |
On Jul 23, 2013, at 04:24 AM, Alexander Belopolsky wrote:
>@contextlib.contextmanager
>def redirect_stdout(stream):
> old_stdout = sys.stdout
> sys.stdout = stream
> yield
> sys.stdout = old_stdout
Make that:
@contextlib.contextmanager
def redirect_stdout(stream):
old_stdout = sys.stdout
sys.stdout = stream
try:
yield
finally:
sys.stdout = old_stdout
and I'll be able to remove those 8 lines of code from all my other code bases
:) |
|