print "Welcome to pythonpy, a Python interpreter written in Python" text = True while text: try: text = raw_input(">> ") while text[-1] in ['\\', ':']: if text[-1] == ':': text += '\\' text += '\n' + raw_input("...") if text in ["quit", "quit()"]: raise KeyboardInterrupt if text: exec(text) except KeyboardInterrupt: text = None except Exception as e: print e try: result = eval(text) if result != None: print str(result) except: pass