开发者

How to use argparse to collect arguments for a separate command line without --?

I'm writing Python programs that run other programs, like:

my-wrapper-program --foo --bar git commit --all

Here, foo and bar are arguments to my-wrapper-program, and git commit --all is the sub-command I'm interested in running. How do I do this in argparse, without having to always specify the -- special开发者_如何转开发 argument? (The common case is the simplest one: my-wrapper-program command.)

(With optparse, you can use disallow_interspersed_args=False.)


This page has some suggestions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜