Created
April 16, 2017 07:18
-
-
Save vikramdurai/82a2aaec2866b9ca353eddc6308a2374 to your computer and use it in GitHub Desktop.
A command-line interpreter for Python
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
"""A basic interpreter for Python, using the eval() function.""" | |
# print startup info | |
print("Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32") | |
print("Type \"copyright\", \"credits\" or \"license()\" for more information.") | |
while True: | |
code = input(">>> ") | |
# try to run the code entered | |
try: | |
eval(code) | |
# if not, catch the error | |
# and throw it to the screen | |
# TODO: Throw tracebacks to the screen too | |
except Exception as err: | |
print(str(err)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment