[Python-Dev] a different approach to argument parsing

Paul Prescod paul@prescod.net
2002年2月12日 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

AltStyle によって変換されたページ (->オリジナル) /