diff options
author | 2018-05-21 18:02:07 +0200 | |
---|---|---|
committer | 2018-05-21 18:02:07 +0200 | |
commit | 964054baf1e02fb017deec9d2f4cd8b65f19944a (patch) | |
tree | 6ce672a025c5f8c59109888f2299b4cfdf21be9b /runner/test.py | |
parent | Initial commit (diff) |
init commit
Diffstat (limited to 'runner/test.py')
-rw-r--r-- | runner/test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runner/test.py b/runner/test.py new file mode 100644 index 0000000..08f0441 --- /dev/null +++ b/runner/test.py @@ -0,0 +1,21 @@ +import sys +from io import StringIO + +def execute(snippet): + old_stdout = sys.stdout + redirected_output = sys.stdout = StringIO() + try: + exec(snippet) + except: + raise + finally: + sys.stdout = old_stdout + + return redirected_output.getvalue() + + +code = """ +i = [0,1,2] +for j in i: + print(j) +""" |