On Thu, Oct 10, 2019 at 2:37 PM brent bejot <brent.be...@gmail.com> wrote: > > > > On Wed, Oct 9, 2019 at 11:01 PM Ryan Gonzalez <rym...@gmail.com> wrote: >> >> I believe you want Python 3.7's parse_intermixed_args: >> https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_intermixed_args >> >> A quick test seems to work: >> >> >> import argparse >> >> p = argparse.ArgumentParser() >> p.add_argument('files', nargs='*') >> p.add_argument('-f', '--force', action='store_true') >> >> print(p.parse_intermixed_args()) >> >> >> $ python3 rm.py x -f y >> Namespace(files=['x', 'y'], force=True) >> $ > > > This is EXACTLY what I've been looking for. Looks like it was added in 2017 > and release in 3.7. The box I use where I investigated this has 3.6 on it. > Sigh, well at least I know it was a good idea! Thanks so much! >
Welp, I learned something new today too :) Thanks Ryan for pointing that out! What you may want to consider is backporting the exact argparse.py from Python 3.7. It's a fairly straight-forward module and will probably work fine on 3.6. That way, once you upgrade to 3.7, it'll keep working the exact same way. 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/MVE5S76AKJ42AM3H2G6B5CC4JJJPDN6E/ Code of Conduct: http://python.org/psf/codeofconduct/