If you want to make a full-fledged interpreter, I would say that you learn pyParsing .
Otherwise,
def parse(string):
words = string.rsplit()
if words[0] == "add":
print int(word[1]) + int(word[2])
parse(raw_input());
Please note that I absolutely do not check for errors; you must have this in your application.
source
share