getopt with negative numbers?

Carl Banks pavlovevidence at gmail.com
Sat Sep 29 21:53:32 EDT 2007


On Sep 29, 7:58 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> Carl Banks <pavlovevide... at gmail.com> writes:
> > On Sep 28, 6:19 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
> > wrote:
> > > Steven Bethard <steven.beth... at gmail.com> writes:
> > > > A user shouldn't have to go out of their way to specify regular
> > > > numbers on the command line, regardless of whether they're
> > > > positive or negative.
>
> > > A user shouldn't have to go out of their way to know whether what
> > > they type on a command line will be treated as an option or an
> > > argument.
>
> > I guess typing
> > ./program --help
>
> > is out of the question.
>
> You're trying to have it both ways.
>
> You're saying the user "shouldn't have to go out of their way" to type
> arbitrary arguments on the command line.

No, I'm not.  Don't put words in my mouth.

I don't think it's "going out of your way" to read the documentation,
or to put a couple hyphens on the line.  Those were your words, and
they were an utterly silly hyperbole.


> Then, in your next message,
> you suggest they must *read the detailed command-line help* in order
> to know whether they *can* type arbitrary command-line arguments.

You're writing a program that takes numerical positional arguments.

Are you being more of asshole ir you
A. Expect me to read the documentation, or
B. Force me to type two hyphens every single time I want to enter a
negative number?

I would say B by a mile.

Not that it's "going out of my way" to enter the extra hyphens; it's
just irritating and completely, totally, and utterly unnecessary.


> Is "learn about how the program expects options and arguments" within
> your definition of "go out of their way", or isn't it? If it's not,
> then "shouldn't have to go out of their way" is *not* an argument in
> favour of special-casing negative-numbers.

It's only a special case in your imagination.  Try typing this:

seq -9 -1

On my system, seq is a GNU tool, and the guys at the FSF are some of
the biggest tightwads around when it comes to command line options.
Even when they allow nonconformant options for the sake of backwards
compatibility, they run a guilt trip on you.  But even they see the
practicality in allowing negative number arguments in some cases.


Carl Banks




More information about the Python-list mailing list