Message169336
| Author |
ncoghlan |
| Recipients |
ncoghlan, rhettinger |
| Date |
2012年08月29日.04:45:44 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1346215545.54.0.365571882897.issue15805@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
We actually use a variant of this idea in the test suite (http://docs.python.org/dev/library/test#test.support.captured_stdout)
It would be pretty easy to combine the two concepts by defaulting the redirection to a new StringIO instance if no other destination is given:
print('This goes to stdout')
with redirect_stdout(sys.stderr):
print('This goes to stderr')
print('So does this')
print('This goes to stdout')
with redirect_stdout() as s:
print('This goes to the io.StringIO instance "s"')
print('So does this')
print('This goes to stdout') |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年08月29日 04:45:45 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger |
| 2012年08月29日 04:45:45 | ncoghlan | set | messageid: <1346215545.54.0.365571882897.issue15805@psf.upfronthosting.co.za> |
| 2012年08月29日 04:45:45 | ncoghlan | link | issue15805 messages |
| 2012年08月29日 04:45:44 | ncoghlan | create |
|