New submission from Pedro:

The possible values for action are currently:
'store'
'store_true'
'store_false'
'store_const'
'append'
'append_const'
'count'
'help'
'version'
a subclass of argparse.Action

The string values are evidently for backward compatibility with optparse. 
However, adding the ability to specify these options as flags would make 
argparse code more maintainable (e.g. IDEs are better at refactoring symbols 
than strings), bring it in line with other places where a module has built-in 
flags, like the regex module (re.MULTILINE, re.IGNORECASE, etc.), and expand 
the use of flags that already exist in argparse (e.g. argparse.SUPPRESS, 
argparse.REMAINDER).

The string values need not be immediately deprecated, but can be made available 
as the preferred option for new development. See, for example, getName() and 
setName() in the threading module, which are documented as follows: "Old 
getter/setter API for name; use it directly as a property instead." A similar 
suggestion can be provided for argparse flags: "Old action values for backward 
compatibility; use the flags instead."

----------
messages: 288445
nosy: pgacv2
priority: normal
severity: normal
status: open
title: argparse values for action in add_argument() should be flags instead of 
(or in addition to) strings
type: enhancement
versions: Python 2.7, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29632>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to