I just wanted to show the basic usage of docopt, a module that makes parsing command-line arguments so much easier. I'm not affiliated with the creators of docopt, but I'm certainly thankful for their work and happy to post this little snippet. I will point you to docopt.org for more information because there is so much more you can do with this module, that I'm not showing you here. Watch the video, it was an eye-opener for me. Also, if you'd like to install docopt you can go to their github repo to download and install it.
Try running this script in different ways to see the results, any invalid arguments will kick the user out to a Usage message (which also happens to be the way docopt recognizes valid or invalid arguments, awesome). The -h and --help flags are automagically recognized and used, so no code for them needs to be written:
./docopt_example.py -h ./docopt_example.py myrequiredargument ./docopt_example.py myrequiredargument -f ./docopt_example.py myrepeatingarg1 myrepeatingarg2 myrepeatingarg3
Edited 3 Years Ago by chriswelborn: comment is showing funny