OptionParser python module - multiple entries of same variable?
Posted
by jduncan
on Stack Overflow
See other posts from Stack Overflow
or by jduncan
Published on 2010-05-03T04:09:40Z
Indexed on
2010/05/03
4:18 UTC
Read the original article
Hit count: 284
I'm writing a little python script to get stats from several servers or a single server, and I'm using OptionParser to parse the command line input.
#!/usr/bin/python
import sys
from optparse import OptionParser
...
parser.add_option("-s", "--server", dest="server", metavar="SERVER", type="string",
help="server(s) to gather stats [default: localhost]")
...
my GOAL is to be able to do something like
#test.py -s server1 -s server2
and it would append both of those values within the options.server object in some way so that I could iterate through them, whether they have 1 value or 10.
Any thoughts / help is appreciated. Thanks.
© Stack Overflow or respective owner