[Python-Dev] a different approach to argument parsing

Paul Prescod paul@prescod.net
Tue, 12 Feb 2002 02:23:47 -0800


I like the general direction but one thing makes me a little confused...

Russ Cox wrote:
> 
>...
> 
>    for o in opt:
>         if o=='-n' or o=='--num':
>                 ncopies = opt.optarg(opt.needtype(int))

How does "opt" know that I am looking for the arguments to the --num
command line argument and not the --file one? I guess I would expect an
interface more like:

for o, value in opt:
    if o=='-n' or o=='--num':
         ncopies = optparser.needtype(value, 'integer')

 Paul Prescod