getopt with negative numbers?

Peter Otten __peter__ at web.de
Thu Sep 27 14:08:05 EDT 2007


Casey wrote:

> On Sep 27, 1:34 pm, Peter Otten <__pete... at web.de> wrote:
>> optparse can handle options with a negative int value; "--" can be used
>> to signal that no more options will follow:
> 
> Thanks, Peter.  getopt supports the POSIX "--" end of options indicator
> as well, but that seems a little less elegant than being able to simply
> set a value that tells the parser "I don't use any numeric values as
> options, and I want to allow negative values as arguments".  At the
> parser level implemening this would be trivial and I frankly was hoping
> it had been implemented and it just wasn't mentioned in the spares
> Python getopt library reference.

After a quick glance into the getopt and optparse modules I fear that both
hardcode the "if it starts with '-' it must be an option" behaviour.

Peter



More information about the Python-list mailing list