Coming back to the question originally set by Python; argparse; how to specify position of positional arguments, I came into a valid use case answering to the question why one would need to do this.
If you have an argument with optional value and an optional positional argument, which is doable with argparse, e.g, from help:
$ myprog.py --help
usage: playargs.py [-h] [-i [I]] [positional [positional ...]]
-----cropped-----
Then the only way of setting '-i' flag without a value 'I' and also get positional values, is to place the '-i' flag at the end. So, if you write
$ myprog.py -i one two three
the 'one' value goes unavoidably to '-i'. If you want all 'one', 'two' and 'three' to be taken as positionals, then only way is to write
$ myprog.py one two three -i
I think there should be a way to restrict the accepted syntax to:
playargs.py [positional [positional ...]] [-i [I]]
The optionality of value 'I' before optional positional arguments makes things unclear.
Is there a way with argparse or other module?