Decorator for main method script shows how to do the same thing with a decorator that makes the code much cleaner.This allows option and argument parsing to be hidden from the main code in your program. The user simply passes an optional getopt string and the number of required arguments. Then the actual main function get passed a dictionary of options and a list of arguments.
One possible improvement would be to add an optional error handling routine passed to the decorator. As it is all exceptions are caught in the decorator function and printed to the screen.