Saturday, February 20, 2010

Python notes, optparse positional argument parsing

    parser = optparse.OptionParser()
    try:
        (options, (first_posarg, second_posarg, )) = parser.parse_args()
    except ValueError:
        parser.error("Two positional arguments are required.")

No comments: