I’m running Python 3.15 under Debian linux version 13. This question refers only to the use of “argparse”, and it is not in any way meant to be any kind of “XY” question. If I can’t do what I describe here using argparse, I already know that there are several other argument-parsing packages for Python, and I know how to use them. In other words, this question is solely about the specific use of argparse, and I am not in any way looking for alternatives to argparse.
I’d like to be able to use argparse to accept alternate names for the same argument, if that is possible.
For one example out of many possibilities, I’d like ‘-o’, and ‘-O’, and ‘–outputfile’, and ‘–outfile’, ‘–output’, and ‘–out’ to all manage the same parameter variable.
I know I can do this via multiple instances of parser.add_argument(), or by calling parser.add_argument() within a “for” loop that loops through all of these argument name values.
But is there any way at all to get argparse to do this via one, single parser.add_argument() call, and without needing a loop?
Except for this issue, I like argparse, and I’m hoping that I won’t need to switch to any alternative argument-parsing utility in order to make use of this capability.
Thank you very much in advance for thoughts and suggestions.