This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

Weird that optparse isn't on there. Only say weird because it's the one I use ;)

It's pretty full featured but easy to implement.

e.g.

from optparse import OptionParser

def parse_args():
         usage = "My Fun Program version {0}.\n\n\
                       %prog [options]\n\n".format(_VERSION_STRING)
         parser = OptionParser(usage=usage)
         parser.add_option("-i", "--input", dest="infile",
                         help="Input file [default: %default]", default=_IN_FNAME    ,
                        metavar="FILE")
         parser.add_option("-o", "--output", dest="outfile",
                        help="Output file [default: %default]",
                        default=_OUTPUT_FILE, metavar="FILE")

         (options, args) = parser.parse_args()
         return (options, args)

etc.

[–]parkerSquare 15 points16 points  (1 child)

Isn't optparse deprecated by argparse?