getopt vs. optparse

Last week I was getting the MessageBroker started for the DustBot project. I needed some code for logging, and starting the server. Since I wanted to have a simple way to specify command line parameters for the MessageBroker I thought about writing some getopt code to do this. This was the time I stumbled upon Poco. Poco is a C++ library that helps to build networking application. One such module provides easy networking to C++. In addition it also provides some helper classes to easily set up a deamon application including parsing the command line parameters.

To parse the command line parameters with Poco was much easier then with getopt and was done very quickly. At this point I thought why do I not have something like this in Python? After a quick search I found optparse a Python module that helps to parse the command line parameters in a much easier way then getopt. To check if it works as easy as it looked like I integrated it into the regexplace script I posted earlier (Change of multiple files). The new version is uploaded to the wiki and can be downloaded from here.
If you need to parse command line parameters with python I recommend the optparse module. Since it really works well and is much easier to use then getopt.

No Comment

Comments are closed.