Python has two modules that pull and parse command line-type options: an older one called getopt, and a newer one (from Python 2.3) called optparse. I’ve used both, though I’ve used getopt a lot more. What I’ve never gotten around to doing before is converting a getopt-based script to an optparse one.

Wow. Conversion is an eye-opener…it makes it clear how much cleaner, straightforward, and powerful optparse is. Don’t get me wrong; getopt has been a workhorse for a long time now. But optparse rocks. If you have stuff you’ve been waiting to switch over, stop waiting. Optparse is REALLY nice.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.