On Thu, Oct 10, 2019 at 1:50 PM brent bejot <brent.be...@gmail.com> wrote: > > Hello all, > > Aspiring contributor here. I am not at all certain that this is the right > place to discuss this. Do refer me to a better location if I'm out of place. >
This is the perfect place to discuss this! Welcome on in. > I would like to add a simple feature to the argparse library. I frequently > find myself writing small utilities, stylistically similar to unix's "rm" > whose main parameter(s) get bundled into a list and it doesn't matter if > flags are sprinkled throughout. > > e.g. "rm foo.txt -f bar.txt" removes both foo.txt and bar.txt forcefully. > > Doing this in argparse currently is cumbersome at best (though I would be > happy to be proved wrong on that), so I rarely implement it as a feature. > > Of note, calling parser.add_argument with nargs="..." or nargs="A..." or > nargs="*" gets close, but will not allow you to intermix other flags between > your list. > > I have a working modification of argparse.py that I could commit, but I know > there's several steps between here and there - I just don't know what those > steps are. > What are the consequences of this change? How does it interact with flags that take arguments (eg if you have "-x spam" in the middle of a list of files)? Does this change affect the way nargs="*" works, or are you creating a slightly different way to do things? This sounds like a useful feature. Next step: More details. :) ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TANUQEJSX4OFAKBYG4TNMBRM6P5YJEBA/ Code of Conduct: http://python.org/psf/codeofconduct/