Skip to content

Instantly share code, notes, and snippets.

@adrinjalali
Last active January 5, 2019 19:23
Show Gist options
  • Save adrinjalali/eca43556ca1620c72d91d8326ca59587 to your computer and use it in GitHub Desktop.
Save adrinjalali/eca43556ca1620c72d91d8326ca59587 to your computer and use it in GitHub Desktop.
Run a python script and get the output as if it was run in the python interpreter.
# run as: python run_script.py < your_script.py
import code
import sys
icon = code.InteractiveConsole()
prompt = '>>>'
for line in sys.stdin:
line = line.rstrip()
print(prompt, line)
prompt = ('...' if icon.push(line) else '>>>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment