Numeric command-line options vs. negative-number arguments
bignose+hates-spam at benfinney.id.au
Fri Sep 28 08:58:23 CEST 2007
Steven Bethard <steven.bethard at gmail.com> writes:
> Did you try it and find it didn't work as you expected?
No, I was commenting on the behaviour you described (hence why I said
"That would be irritating").
> Argparse knows what your option flags look like, so if you specify
> one, it knows it's an option. Argparse will only interpret it as a
> negative number if you specify a negative number that doesn't match
> a known option.
That's also irritating, and violates the expected behaviour. It leads
to *some* undefined options being flagged as errors, and others
interpreted as arguments. The user shouldn't need to know the complete
set of options to know which leading-hyphen arguments will be treated
as options and which ones won't.
The correct behaviour would be to *always* interpret an argument that
has a leading hyphen as an option (unless it follows an explicit '--'
option), and complain if the option is unknown.
\ "When I was a kid I used to pray every night for a new bicycle. |
`\ Then I realised that the Lord doesn't work that way so I stole |
_o__) one and asked Him to forgive me." -- Emo Philips |
More information about the Python-list