[issue26181] argparse can't handle positional argument after list (help message is wrong)

paul j3 report at bugs.python.org
Wed Jan 27 19:19:19 EST 2016


paul j3 added the comment:

There are 2 issues

parsing - how to reserve one or more arguments for use by following 'positionals'.  Fixes have been proposed in other bug/issues, but aren't trivial.

usage formatting - the stock formatter displays all optionals first, followed by all positionals.  In a multiline display positionals go on a new line.

Changes to the help formatter that would block this reordering have been discussed on Stackoverflow, but I don't recall such an issue here.  It can be done by changing one method in a subclassed formatter.

The immediate solution is to give your parser a custom usage line - one that puts the positional in the correct order.

----------
nosy: +paul.j3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26181>
_______________________________________


More information about the Python-bugs-list mailing list