optparse and negative numbers as positional arguments

Grant Edwards grante at visi.com
Wed Apr 6 10:42:32 EDT 2005


On 2005-04-06, Tomi Silander <tsilande at hiit.fi> wrote:
> Grant Edwards wrote:
>
>> On 2005-04-05, Tomi Silander <tsilande at hiit.fi> wrote:
>
>>>How is one supposed to give negative numbers as positional
>>>arguments when using optparse?
>> 
>>   ./mitvit.py -- -1.1
>
> this works.

Yes, I know. :)

> I saw it in the source, but apparently did not properly pay
> attention; all the args after "--" are considered positional
> if I read this right.

That's the way it's traditionally been done.  I just assumed
that optparse did it that way, and when I tried it with
optparse it seemed to work the same.  It's not mentioned in the
optparse documentation anywhere (it probably should be).

-- 
Grant Edwards                   grante             Yow!  .. are the STEWED
                                  at               PRUNES still in the HAIR
                               visi.com            DRYER?



More information about the Python-list mailing list