optparse is marked as deprecated, use argparse instead.

> Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.

I believe it will be a drop in replacement for the changes you are making.