problem with optparse

N

Neal Becker

This example is right out of python library reference. What's wrong here?

import optparse

def store_value(option, opt_str, value, parser):
setattr(parser.values, option.dest, value)

parser = optparse.OptionParser()
parser.add_option("--foo",
action="callback", callback=store_value,
type="int", nargs=3, dest="foo")

(opt,args) = parser.parse_args ('--foo a b c'.split())

[...]
/usr/lib64/python2.5/optparse.pyc in _process_args(self, largs, rargs, values)
1423 elif self.allow_interspersed_args:
1424 largs.append(arg)
-> 1425 del rargs[0]
1426 else:
1427 return # stop now, leave this arg in rargs

TypeError: 'str' object doesn't support item deletion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top