optparse, allowing both --foo and foo=99?

Mark Harrison mh at ohm.dynamic.pixar.com
Fri Oct 16 01:29:53 EDT 2009


What's the magic to allow this?  If the value is not specified I
would like to use the default value of 1.

import optparse
p=optparse.OptionParser()
p.add_option("--debug")

(opts, args) = p.parse_args(['--debug=22']); print opts
(opts, args) = p.parse_args(['--debug']);    print opts

Many TIA!
Mark

-- 
Mark Harrison
Pixar Animation Studios



More information about the Python-list mailing list