getopt with negative numbers?

Neal Becker ndbecker2 at gmail.com
Fri Sep 28 06:35:29 EDT 2007


Ben Finney wrote:

> Casey <Caseyweb at gmail.com> writes:
> 
>> Well, it is a hack and certainly not as clean as having getopt or
>> optparse handle this natively (which I believe they should).
> 
> I believe they shouldn't because the established interface is that a
> hyphen always introduced an option unless (for those programs that
> support it) a '--' option is used, as discussed.

I don't agree.  First of all, what is 'established interface'?  There are
precedents from well-known C and C++ libraries, such as 'getopt', 'popt',
and boost::program_options.  IIRC, each of these will treat a negative
number following an option that requires a number as a number.

Besides this, the behavior I just described is really required.  Otherwise,
numeric options are basically broken.





More information about the Python-list mailing list