Issue 83 in argparse: When -h is used, default values that fail should not matter

1 view
Skip to first unread message

argp...@googlecode.com

unread,
Oct 25, 2011, 3:28:11 PM10/25/11
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 83 by joshc...@gmail.com: When -h is used, default values that
fail should not matter
http://code.google.com/p/argparse/issues/detail?id=83

What steps will reproduce the problem?
1. Make a script containing this code:

parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input-base-directory',
type=argparse.FileType('r'),
default='/home')
parser.parse_args()

2. Run the script with '-h'.
3. See it complain that '/home' is a directory

What is the expected output? What do you see instead?
With '-h', we just need to print the help message. We shouldn't fail on a
default value that's wrong or else the help message will not get printed
and the user will have no idea what the problem is. This is a valid use
case as I want to provide a default location, but I can't guarantee that
the location exists on the user's machine. I end up doing my own checking.

What version of the product are you using? On what operating system?
1.1 on Fedora 15.

Please provide any additional information below.


argp...@googlecode.com

unread,
Oct 26, 2011, 3:48:50 PM10/26/11
to argpar...@googlegroups.com

Comment #1 on issue 83 by denver.c...@gmail.com: When -h is used, default

This issue needs to be instead logged at http://bugs.python.org. Note,
however, that the failure occurs long before -h is processed. I suspect,
actually, thatDoing what you suggest requires a two-pass scan of the
arguments, first looking for some special one, -h, and then, if not
present, scanning it "normally". This doesn't at all fit into the current
design of argparse unfortunately. In principal, though, I definitely
agree. Someone needs to design the mother of all command-line argument
parsers which supports multiple passes :)

argp...@googlecode.com

unread,
Oct 26, 2011, 5:27:25 PM10/26/11
to argpar...@googlegroups.com

Comment #2 on issue 83 by joshc...@gmail.com: When -h is used, default

Ok, submitted on bugs.python.org:
http://bugs.python.org/issue13271


Reply all
Reply to author
Forward
0 new messages