Created
May 14, 2018 19:31
-
-
Save nikhilkumarsingh/0a0226788df9d93ab7cc76fe97d620f0 to your computer and use it in GitHub Desktop.
A simple Python Interactive Shell
This file contains hidden or 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
while 1: | |
x = input(">>> ") | |
if x == 'exit': | |
break | |
try: | |
y = eval(x) | |
if y: print(y) | |
except: | |
try: | |
exec(x) | |
except Exception as e: | |
print("error:", e) |
this code is great thank you
there is an error at line 9 cannot use bare except
Can anyone make it work in python2?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice