Issue 69 in argparse: Request: Method for prompting for arguments let out

0 views
Skip to first unread message

argp...@googlecode.com

unread,
Apr 4, 2010, 8:27:03 PM4/4/10
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 69 by AndrewAlex: Request: Method for prompting for arguments let
out
http://code.google.com/p/argparse/issues/detail?id=69

For programs requiring a large number of arguments I make my them optional
and then do something like the code below. This (or a more integrated
implementation) may be useful for argparse.


args = parser.parse_args()
prompt_for_arg(args.name, "Name: ")
prompt_for_arg(args.company, "Company: ")
prompt_for_arg(args.homedir, "Users Home Directory: ")

def prompt_for_arg(argfield, prompt):
if argfield is not None:
return False
try:
argfield = input(prompt)
if len(argfield) > 0:
return True
except:
pass
print("Aborted")
sys.exit()

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

argp...@googlecode.com

unread,
Apr 4, 2010, 9:01:23 PM4/4/10
to argpar...@googlegroups.com

Comment #1 on issue 69 by AndrewAlex: Request: Method for prompting for

I was too rough in stripping out the code above, the function above does
not work.
This one should

def prompt_for_arg(arg, field, prompt):
if getattr(arg, field) is not None:
return False
try:
r = input(prompt)
if len(r) > 0:
setattr(arg, field, r)

argp...@googlecode.com

unread,
Jul 23, 2010, 9:43:29 AM7/23/10
to argpar...@googlegroups.com
Updates:
Status: WontFix

Comment #2 on issue 69 by steven.bethard: Request: Method for prompting for

Closing as WontFix, mainly because I didn't see any additional community
requests for it. Feel free to open a new issue at bugs.python.org
(argparse's new home) if you know of others asking for similar behavior.

Reply all
Reply to author
Forward
0 new messages