Message156276
| Author |
bethard |
| Recipients |
bethard, eric.smith, jeffknupp, kalt, r.david.murray, wt |
| Date |
2012年03月18日.21:41:39 |
| SpamBayes Score |
7.598379e-07 |
| Marked as misclassified |
No |
| Message-id |
<1332106899.97.0.563731511313.issue13922@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> It prevents implementing parsers that pass strings on to another
> sub-parser or command.
...
> wouldn't you use 'parse_known_args' instead of 'parse_args'
> and pass the remaining arguments to the next script
I'll just say again that the recommended way of passing arguments to another command is via nargs=argparse.REMAINDER. (Though you may still need "--" if the first argument in the remainder is a flag shared by your parser, as Warren Turka pointed out.)
> I really want "--" to mean "treat everything else as non-optional
> arguments"
Yep, and that's what it's intended to mean, and what the documentation says:
"you can insert the pseudo-argument '--' which tells parse_args() that everything after that is a positional argument"
http://docs.python.org/library/argparse.html#arguments-containing
It's therefore a bug if there's a '--' after the first '--', but it's not being treated as a positional argument. |
|