Simulating CLI Shell with python
问题 I was asked to simulate CLI with Python. This is what I did def somefunction(a,b): //codes here //consider some other functions too print "--- StackOverFlow Shell ---" while True: user_input = raw_input("#> ") splitit = user_input.split(" ") if splitit[0] == "add": firstNum = splitit[1] sNum = splitit[2] result = somefunction(firstNum, sNum) print result //consider some other elif blocks with "sub", "div", etc else: print "Invalid Command" I do also check the length of the list, here "splitit