I use optparse.OptionParser to manage the arguments for some scripts, and something that I was interested / would like to do is to have boolean flags (i.e. action=store_true ) that can also take a parameter.
To include this in context, I have an application that can use as many GPUs / processors as it finds on the machine. For various reasons, sometimes you want to limit the number of devices that it uses, and instead of further cluttering the command line, I would like to be able to:
script -c -g
means using everything you can from all cpus and gpus, and
script -c 2 -g 3
means restricting script execution to 2 processors and 3 GPUs.
After reading the optparse documentation, I'm no wiser. Oh great SO gurus! Lend me your wisdom!
source share