Author paul.j3
Recipients Markus.Amalthea.Magnuson, SylvainDe, bethard, docs@python, paul.j3, r.david.murray
Date 2014-06-19.16:22:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403194970.66.0.0372070419653.issue16399@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-06-19 16:22:50paul.j3setrecipients: + paul.j3, bethard, r.david.murray, docs@python, Markus.Amalthea.Magnuson, SylvainDe
2014-06-19 16:22:50paul.j3setmessageid: <1403194970.66.0.0372070419653.issue16399@psf.upfronthosting.co.za>
2014-06-19 16:22:50paul.j3linkissue16399 messages
2014-06-19 16:22:50paul.j3create