getopt with negative numbers?

Nanjundi nanjundi at gmail.com
Thu Sep 27 21:33:04 CEST 2007


On Sep 27, 1:34 pm, Peter Otten <__pete... at web.de> wrote:
...
> >>> args
>
> ['-123']
>
> Without the "--" arg you will get an error:
>
> >>> parser.parse_args(["-123"])
>
> Usage:  [options]
>
> : error: no such option: -1
> $
>
> Peter

Passing -a-123 works
>>> options, args = parser.parse_args(["-a-123"])
>>> options.a
-123

-N




More information about the Python-list mailing list