Optparse library - callback action while storing arg

My code:

def main():
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)
    parser.add_option("-p", "--pending", action="callback", callback=pending, type="string", dest="test", help="View Pending Jobs")
    (options, args) = parser.parse_args()
    if x == 0:
        print usage, " (-h or --help for help)"
    print options.test

if i had: script -p hello

i need options.test to print out the argument as type string

13.10.2009 13:00:29
If your using optparse it will generate the help info for you automatically. use "parser.print_help()".
monkut 13.10.2009 13:24:04
I've been looking at that and the library documentation for over an hour now
user177215 13.10.2009 13:28:46
Why in the world are you using a 'callback' option? Remove the 'action=" and 'callback=' and even 'type=' parameters and it will do what you want.
Andrew Dalke 14.10.2009 21:37:29

The arguments are available through sys.argv.

13.10.2009 14:20:29

Ended up passing the argument to the function that is being called.

13.10.2009 13:37:46