Created
November 14, 2012 16:38
-
-
Save squirly/4073190 to your computer and use it in GitHub Desktop.
REPL
This file contains 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
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