getopt: where's da dicts?????
Les Schaffer
godzilla at netmeg.net
Mon Oct 18 13:02:49 EDT 1999
just started using the getopt module. i was surprised to see it
returns the options in list format rather than perl's (better)
dictionary format.
i thought i read on c.l.p many moons ago about someone who had written
an add-on to getopt to return a dict of options a la perl. but i found
nothing in deja news for this.
anyone have a pointer to such solution (before i implement it myself),
i'd do something like this:
def make_dicts_from_opts( opts ):
options = {}
for item in opts:
options[item[0]] = item[1]
return options
import getopt
...
opts, args = getopt.getopt(sys.argv[1:], 'dhu:v')
opts = make_dicts_from_opts(opts)
return opts,args
...
etc etc
les schaffer
More information about the Python-list
mailing list