Vimport sys, optparse, os, ConfigParser import functions # our modules parser = optparse.OptionParser("%prog yourname@yourdomain.org \"Your support message\" [options]") config = ConfigParser.ConfigParser() config.readfp(open('list.conf')) for x in config.sections(): sflag = config.get(x, "sflag") lflag = config.get(x, "lflag") command = config.get(x, "command") help = config.get(x, "help") print sflag print lflag parser.add_option('"%s", "%s", action="store_true", help="%s", default=False)' % (sflag, lflag, help) (options, args) = parser.parse_args() --- config file ---- [standard] sflag=-s lflag=--standard command=dmesg help=test [network] sflag=-n lflag=--network command=cat /var/log/daemon.log help=network stuff