Command-Line Argument Processing for the Lazy: Python's argparse Module
Like many of you, I write a lot of throwaway scripts to do a task. These are quick undocumented 20-line blobs of code that do janitorial or maintenance tasks and they're deleted almost as soon as they're written. But if something is going to endure, I try to take a more professional approach: documentation and comments, logging, checking sub-command errors, failing gracefully - and handling command-line arguments. In fac...
Read More