Message155062
| Author |
bethard |
| Recipients |
bethard, guilherme-pg, v+python |
| Date |
2012年03月07日.09:06:46 |
| SpamBayes Score |
3.2889012e-09 |
| Marked as misclassified |
No |
| Message-id |
<1331111208.1.0.942593790703.issue14191@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> optparse, which argparse attempts to replace, permitted positional
> arguments to be intermixed with optional arguments
Sure, but optparse didn't actually parse positional arguments - it just threw them into a bag, and then you had to group them and convert them however you wanted afterwards. Argparse, instead, was designed to let you specify the groups of positional arguments. Your situation is a little different because you just want to throw all the positional arguments into a bag again. Not that there's anything wrong with that - it's just not the primary use case argparse had in mind.
> The only definition of positional parameters I could find...
Yeah, it looks like there's no good documentation on positional vs. optional parameters. Somewhere obvious, perhaps right at the beginning of the add_argument() documentation, there should probably be something like:
Argparse groups the command line argument strings into two types of groups: optional arguments, which are a sequence of command line strings that begin with a flag like "-v" or "--verbose", and positional arguments, which are a sequence of command line strings that do not begin with a flag. The add_argument() method allows you to specify how many command line strings each of your optional or positional arguments should consume, how those strings should be converted into Python objects, etc. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年03月07日 09:06:48 | bethard | set | recipients:
+ bethard, v+python, guilherme-pg |
| 2012年03月07日 09:06:48 | bethard | set | messageid: <1331111208.1.0.942593790703.issue14191@psf.upfronthosting.co.za> |
| 2012年03月07日 09:06:47 | bethard | link | issue14191 messages |
| 2012年03月07日 09:06:46 | bethard | create |
|