 from __future__ import unicode_literals <EOL> import sys <EOL> from contextlib import contextmanager <EOL> from tempfile import TemporaryFile <EOL> try : <EOL> from io import StringIO <EOL> except ImportError : <EOL> from cStringIO import StringIO <EOL> @ contextmanager <EOL> def capture ( ) : <EOL> old_stdout = sys . stdout <EOL> with StringIO ( ) as tmp : <EOL> sys . stdout = tmp <EOL> try : <EOL> yield tmp <EOL> finally : 
 sys . stdout = old_stdout </s>

 from __future__ import unicode_literals <EOL> import sys <EOL> from contextlib import contextmanager <EOL> from tempfile import TemporaryFile <EOL> try : <EOL> from io import StringIO <EOL> except ImportError : <EOL> from cStringIO import StringIO <EOL> @ contextmanager <EOL> def capture ( ) : <EOL> old_stdout = sys . stdout <EOL> with StringIO ( ) as tmp : <EOL> sys . stdout = tmp <EOL> try : <EOL> yield tmp <EOL> finally : <EOL> sys . stdout = old_stdout </s>
