paul j3 added the comment: What you are asking about is the fact that different arguments can share a 'dest'.
https://docs.python.org/3/library/argparse.html#dest The 'append_const' action has an example of shared 'dest'. It says: The 'append_const' action is typically useful when multiple arguments need to store constants to the same list. I've suggested 'dest' sharing in some SO questions. Shared 'dest' may be a nuisance in the case of regular 'store' actions, since only the last value is retained. But that also happens if a user repeats an argument. Usually errors like this become apparent during development testing, and can be easily fixed with changes to the 'dest' parameter. The 'conflict handler' mechanism does prevent conflicts in the option strings. But it does not check the 'dest'. In fact the parser does not maintain a list or dictionary of 'dest'. It looks that up on the Actions as needed. A simple function that would collect actions by 'dest' could use: dd = collections.defaultdict(list) for a in parser._actions: dd[a.dest].append(a) Or the developer could collect their own list of Actions. So it is easy to test for repeated 'dest', but I don't think it is generally needed or useful. Custom Action classes can also be used to test for repeat assignments to a given 'dest' (objecting, for example, if the existing value in the Namespace is not the default). ---------- nosy: +paul.j3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25308> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com