[Python-Dev] Python 2.7b1 and argparse's version action (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Sun Apr 18 13:03:34 CEST 2010


Tobias Herp wrote:

Before Python 2.7 reaches productivity stage, IMNSHO the following changes should be applied to argparse.py:

- removal of the deprecation warnings - removal of the default usage of '-v' with the version information facility This is a very simple thing to do; I'd happily provide a patch. (The only complicated task might be to make the unit tests reflect the change; but for a start, 7 lines of the testmain function could be dropped.) Just for the records, this is what optparse does: - it defines -h and --help for the help (unless suppressed) - it defines --version for the version (if version argument given) This is how it should be (regarding the version, at least). This is how the vast majority of *x tools looks like. No reason to change this behaviour. What do you think?

I can see Steven's argument from an argparse point of view, but I think he is taking backwards compatibility to an unhealthy extreme.

Deprecating a perfectly valid option just because someone might be relying on -v instead of -V as the shorthand for version? A phrase involving babies and bathwater comes to mind...

I would be a lot happier if argparse as a standard library module just followed optparse's lead here (i.e. defined '--version' only and punted on the shorthand form).

To deal with this in a backwards compatible way while remaining on the path to more conventional behaviour, I suggest the following:

  1. For Python 2.7, deprecate just the "-v" default behaviour for the version. This means "--version" and "-v" will be set to invoke different actions when the version argument is supplied (the latter will trigger a deprecation warning if supplied, while the former will work normally).

  2. For Python 3.2, don't create the "-v" shorthand at all (i.e. only create "--version").

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list