Skip to content

Instantly share code, notes, and snippets.

@squirly
Created November 14, 2012 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squirly/4073190 to your computer and use it in GitHub Desktop.
Save squirly/4073190 to your computer and use it in GitHub Desktop.
REPL
print('Tyler\'s python implementation of REPL.\n')
while True:
# Read - Get user input
read_value = raw_input('Ty\'s PyREPL >>> ')
# Eval - Run user input
try:
try:
out = eval(read_value)
except SyntaxError:
try:
exec(read_value)
out = None
except:
raise
except Exception, e:
out = e
# Print - Show the result
if out:
print(out)
# Loop - Do it again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment