Python; argparse; how to specify position of positional arguments

烈酒焚心 提交于 2019-12-01 07:31:01
hpaulj

The default usage formatter separates the positional arguments from the optionals, and displays them at the end. In the case of multiline displays like this, the positionals are put on a separate line. That is what you are seeing.

When parsing positionals can come first.

An obvious way around this is to supply your own usage string, but with this many arguments I can understand not wanting to do so.

https://stackoverflow.com/a/26986546/901925 (last November) has a HelpFormatter patch that disables this reordering. But as written it only applies to single line usage. Multiline usage is handled later in the same method.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!