Feature Requests item #1627266, was opened at 2007-01-03 13:46 Message generated for change (Comment added) made by draghuram You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1627266&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Raghuram Devarakonda (draghuram) Assigned to: Greg Ward (gward) Summary: optparse "store" action should not gobble up next option Initial Comment: Hi, Check the following code: --------------opttest.py---------- from optparse import OptionParser def process_options(): global options, args, parser parser = OptionParser() parser.add_option("--test", action="store_true") parser.add_option("-m", metavar="COMMENT", dest="comment", default=None) (options, args) = parser.parse_args() return process_options() print "comment (%r)" % options.comment --------------------- $ ./opttest.py -m --test comment ('--test') I was expecting this to give an error as "--test" is an option. But it looks like even C library's getopt() behaves similarly. It will be nice if optparse can report error in this case. ---------------------------------------------------------------------- >Comment By: Raghuram Devarakonda (draghuram) Date: 2007-01-05 12:58 Message: Logged In: YES user_id=984087 Originator: YES It is possible to deduce "--test" as an option because it is in the list of options given to optparse. But your point about what if the user really wants "--test" as an option argument is valid. I guess this request can be closed. Thanks, Raghu. ---------------------------------------------------------------------- Comment By: David Goodger (goodger) Date: 2007-01-05 11:28 Message: Logged In: YES user_id=7733 Originator: NO I think what you're asking for is ambiguous at best. In your example, how could optparse possibly decide that the "--test" is a second option, not an option argument? What if you *do* want "--test" as an argument? Assigning to Greg Ward. Recommend closing as invalid. ---------------------------------------------------------------------- Comment By: Raghuram Devarakonda (draghuram) Date: 2007-01-05 10:19 Message: Logged In: YES user_id=984087 Originator: YES I am attaching the code fragment as a file since the indentation got all messed up in the original post. File Added: opttest.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1627266&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com