optparse

Torsten Mohr tmohr at s.netic.de
Tue Sep 16 15:35:05 EDT 2008


Hi,

i use the module optparse to parse the command line:

------example
#! /usr/bin/python

import optparse

parser = optparse.OptionParser()

parser.add_option("-v", "--verbose",
                  dest = 'verb',
                  help = 'be loud',
                  action = 'store_true',
                  default = 'store_false')

(opts, args) = parser.parse_args()

print "opts", opts
print "args", args
------example

If i call it without any parameters i get:

opts {'verb': 'store_false'}
args []


I would rather like to see the actual value False in "opts",
did i use some wrong parameters somewhere?  I can't imagine
that this is the wanted behaviour of optparse.


Thanks for any hints,
Torsten.





More information about the Python-list mailing list