I'm using Python's cmd module to write my own command line interpreter. I'm not sure how to handle errors using the modules.
Let's say my command
The function usually goes as follows:
Let's say my command
eat
requires 1 argument.The function usually goes as follows:
def do_eat(self, arg): args = arg.split() if len(args) < 1: print("Missing arguments!") returnHowever, I was wondering if one could write it as:
def do_eat(self, arg): args = arg.split() if len(args) < 1: raise "Missing arguments" # Or raise an enum