I have python code something like:
from string import Template
import optparse
def main():
usage = "usage: %prog options outputname"
p = optparse.OptionParser(usage)
p.add_option('--optiona', '-a', default="")
p.add_option('--optionb', '-b', default="")
options, arguments = p.parse_args()
t = Template('Option a is ${optiona} option b is ${optionb}')
print t.substitute(options)
But that gives me
AttributeError: Values instance has no attribute '__getitem__'
Because options
is a Values and not a dictionary.
How do I neatly make this work?
(any other suggestions welcome, my pythonic sense is still being nurtured...)