Message221005
It should be easy to write a subclass of Action, or append Action, that does what you want. It just needs a different `__call__` method. You just need a way of identifying an default that needs to be overwritten as opposed to appended to.
def __call__(self, parser, namespace, values, option_string=None):
current_value = getattr(namspace, self.dest)
if 'current_value is default':
setattr(namespace, self.dest, values)
return
else:
# the normal append action
items = _copy.copy(_ensure_value(namespace, self.dest, []))
items.append(values)
setattr(namespace, self.dest, items)
People on StackOverFlow might have other ideas. |
|
Date |
User |
Action |
Args |
2014-06-19 16:22:50 | paul.j3 | set | recipients:
+ paul.j3, bethard, r.david.murray, docs@python, Markus.Amalthea.Magnuson, SylvainDe |
2014-06-19 16:22:50 | paul.j3 | set | messageid: <1403194970.66.0.0372070419653.issue16399@psf.upfronthosting.co.za> |
2014-06-19 16:22:50 | paul.j3 | link | issue16399 messages |
2014-06-19 16:22:50 | paul.j3 | create | |
|