Problem with optparser or In

Florian Lindner Florian.Lindner at xgm.de
Wed Feb 25 04:32:51 EST 2004


Hi,
I'm not sure where the problems lies...
I'm using optparse and I've a option defined:

 parser.add_option("-t", "--type", action="callback",
callback=option_callback, type="string")

def option_callback(option, opt, value, parser, *args, **kwargs):
    if (str(option) == "-t/--type") and (opt in ("mailbox", "ftp")):
        print "Error!"
    else:
        parser.values.type = opt

This should print error if the commandline is "--type=ftp" or
"--type=mailbox" (same for the short args).
But it never gets till Error... Although opt contains "mailbox" or "ftp".
What's wrong there?


Thanks,
Florian



More information about the Python-list mailing list