[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2019-01-18 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Closing per paul.j3's last comment which also is mentioned in the documentation 
(https://docs.python.org/3.8/library/argparse.html#default
):

> For positional arguments with nargs equal to ? or *, the default value is 
> used when no command-line argument was present

--
nosy: +cheryl.sabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2019-01-18 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2013-10-14 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
nosy: +bethard

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15613
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2013-10-14 Thread paul j3

paul j3 added the comment:

Looks like this behavior is intentional.  This subclass adds a '%(default)s' 
string to the help lines if:

if '%(default)' not in action.help:
if action.default is not SUPPRESS:
defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
help += ' (default: %(default)s)'

So it adds the default if it is an `optional`, or a `positional` with '*' or 
'?'.  

A `default` value for a required positional (including '+') does not make 
sense, since the user input always overwrites the default.  

(I recommend closing this issue).

--
nosy: +paul.j3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15613
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2012-08-10 Thread Alex Jurkiewicz

New submission from Alex Jurkiewicz:

Sample code:

#!/usr/bin/env python
import argparse

print(\n\narg=foo, nargs=+)
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('foo', nargs='+', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print(\n\narg=foo, nargs=*)
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('foo', nargs='*', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print(\n\narg=--foo, nargs=+)
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--foo', nargs='+', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print(\n\narg=--foo, nargs=*)
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--foo', nargs='*', help='foos', default=['foo1', 'foo2'])
parser.print_help()


The first example's help text for 'foo' is missing (default: ['foo1', 
'foo2']). I tested 2.7.2, 2.7.3, 3.2.3.

--
components: Library (Lib)
messages: 167854
nosy: Alex.Jurkiewicz
priority: normal
severity: normal
status: open
title: argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and 
nargs=+
type: behavior
versions: Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15613
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com