Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Created May 14, 2018 19:31
Show Gist options
  • Select an option

  • Save nikhilkumarsingh/0a0226788df9d93ab7cc76fe97d620f0 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

1gahs81 commented Nov 30, 2021

nice

@TheBruschettaBrother
Copy link
Copy Markdown

this code is great thank you

@supermario-2001
Copy link
Copy Markdown

there is an error at line 9 cannot use bare except

@funte
Copy link
Copy Markdown

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