Created
June 16, 2016 02:02
-
-
Save badbye/2349475c3b340558bd14870cd11b6434 to your computer and use it in GitHub Desktop.
stringio.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeOut = StringIO.StringIO() | |
codeErr = StringIO.StringIO() | |
sys.stdout = codeOut | |
sys.stderr = codeErr | |
exec code | |
sys.stdout = sys.__stdout__ | |
sys.stderr = sys.__stderr__ | |
error_output = codeErr.getvalue().strip() | |
normal_output = codeOut.getvalue().strip() | |
codeOut.close() | |
codeErr.close() |
Author
badbye
commented
Jun 17, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment