[Python-Dev] Python 2.7b1 and argparse's version action

Steven Bethard steven.bethard at gmail.com
Sun Apr 18 21:33:28 CEST 2010


On Sun, Apr 18, 2010 at 3:31 AM, Tobias Herp <Tobias.Herp at gmx.de> wrote:
> To put it short:
> *Argparse should simply do this like optparse does already.*
> I.e., use '--version', '--help' and '-h' by default, but not '-v'.
[snip]
> What happened was the following:
> Completely unnecessarily, the 'version' constructor argument is now
> deprecated.
[snip]
> The deprecation of the 'version' argument press-gangs people to replace
> it by
>  parser.add_argument('--version', action='version',
>                      version='<the version>',    # the only common part
>                      help="show program's version number and exit")

What Tobias has conveniently omitted is that there was not much
agreement on what the default behavior of the version flag should be.
Things that were proposed:

* Use both -v and --version
* Use both -V and --version
* Use just --version
* Print out just the version string
* Print out program name with the version string

I put up a poll and asked people for feedback on some of the alternatives:

http://www.vizu.com/res/Grab-bag/argparse/poll-results.html?n=192933

And it was far from a consensus. Given the lack of consensus, the many
different options people thought were the "right" way to do things,
and the fact that the action='version' approach allows people to
customize the flags to whatever they want, I stick by my decision to
deprecate the constructor argument and redirect people to the more
flexible add_argument approach. In the face of ambiguity, refuse the
temptation to guess.

In general, I should say that I'm not opposed to changing the behavior
in Python trunk, even if it causes a bit of backwards incompatibility.
But I'd really like a consensus about the correct behavior, and so far
I have not seen that.

Steve
-- 
Where did you get that preposterous hypothesis?
Did Steve tell you that?
        --- The Hiphopopotamus


More information about the Python-Dev mailing list