| CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Mon, 29 Dec 2025 17:54:39 GMT
content-type: text/html; charset=utf-8
expires: Mon, 29 Dec 2025 17:54:38 GMT
cache-control: no-cache
x-frame-options: sameorigin
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-permitted-cross-domain-policies: none
content-encoding: gzip
x-clacks-overhead: GNU Terry Pratchett
strict-transport-security: max-age=315360000; includeSubDomains; preload
Issue 16988: argparse: PARSER option for nargs not documented - Python tracker
- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue16988
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013-01-17 21:30 by Robert, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg180155 - (view) | Author: Robert Leenders (Robert) | Date: 2013-01-17 21:30 | |
There is a value for nargs: PARSER="A..." which is not documented at https://docs.python.org/3.4/library/argparse.html#nargs. The docstring for the action class in argparse.py also does not list PARSER as a valid value for nargs. In argparse.py on line 2199-2201 it says: # Allow one argument followed by any number of options or arguments elif nargs == PARSER: nargs_pattern = '(-*A[-AO]*)' This is the only hint that I could find on what it is about. |
|||
| msg180195 - (view) | Author: Jeff Knupp (jeffknupp) * | Date: 2013-01-18 15:11 | |
This is not a bug. The 'PARSER' nargs choice is an implementation detail as a way to handle subparsers. The parser needs to know that the first value should be handled, but everything that follows will be handled by the subparser. By using a subparser, you're effectively using 'PARSER', but it wouldn't make sense to allow 'PARSER' to be set directly as it only makes sense when used in conjunction with a subparser. |
|||
| msg187140 - (view) | Author: paul j3 (paul.j3) * ![]() |
Date: 2013-04-17 04:14 | |
I've experimented with an argparse adaptation of profile.py:
parser = argparse.ArgumentParser(usage=usage)
parser.add_argument('-o', '--outfile', dest="outfile",
help="Save stats to <outfile>", metavar="path")
parser.add_argument('-s', '--sort', dest="sort",
help="Sort order when printing to stdout ...",
default=-1)
parser.add_argument('args', nargs=argparse.PARSER,
metavar="scriptfile [arg] ...")
# expect at least one positional, a py module
It is somewhat like subparsers, but without defined subparser choices. Or you could say that PARSER (A...) is to REMAINDER (...) as '+' is to '*'. It requires at least one argument. I could, just as well, have created two arguments, 'scriptfile' and 'args' (with '...').
I don't know if that is an argument for documenting it or not.
|
|||
| msg301233 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2017-09-04 17:45 | |
I don't think this use case is enough to justify documenting it, since this is not an intuitive meaning of the word PARSER. I think if we wanted to expose this for this kind of use case, we'd want to rename the constant (with an alias for backward compatibility), which would be an enhancement. I'm going to close this, but someone who wants this could open an enhancement request. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:40 | admin | set | github: 61192 |
| 2017-09-04 17:45:19 | r.david.murray | set | status: open -> closed type: enhancement -> nosy: + r.david.murray messages: + msg301233 resolution: not a bug stage: resolved |
| 2013-04-17 04:14:36 | paul.j3 | set | nosy:
+ paul.j3 messages: + msg187140 |
| 2013-01-18 15:11:01 | jeffknupp | set | nosy:
+ jeffknupp messages: + msg180195 |
| 2013-01-17 21:38:10 | chris.jerdonek | set | nosy:
+ chris.jerdonek |
| 2013-01-17 21:30:15 | Robert | create | |


