why are you using optparse and not argparse? optparse is deprecated since python 2.7: http://docs.python.org/2/library/optparse.html