[ python-Feature Requests-1627266 ] optparse "store" action should not gobble up next option
SourceForge.net
noreply at sourceforge.net
Fri Jan 5 16:19:29 CET 2007
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: Nobody/Anonymous (nobody)
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 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
More information about the Python-bugs-list
mailing list