F
Florian Lindner
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
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