Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Created May 14, 2018 19:31
Show Gist options
  • Save nikhilkumarsingh/0a0226788df9d93ab7cc76fe97d620f0 to your computer and use it in GitHub Desktop.
Save nikhilkumarsingh/0a0226788df9d93ab7cc76fe97d620f0 to your computer and use it in GitHub Desktop.
A simple Python Interactive Shell
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)
@1gahs81
Copy link

1gahs81 commented Nov 30, 2021

nice

@TheBruschettaBrother
Copy link

this code is great thank you

@kloodi2020
Copy link

there is an error at line 9 cannot use bare except

@funte
Copy link

funte commented Jun 15, 2022

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