[Python-Dev] Python 2.7b1 and argparse's version action (original) (raw)
Tobias Herp Tobias.Herp at gmx.de
Sun Apr 18 23:35:06 CEST 2010
- Previous message: [Python-Dev] Python 2.7b1 and argparse's version action
- Next message: [Python-Dev] Python 2.7b1 and argparse's version action
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven Bethard schrieb:
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.addargument('--version', action='version', 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.
Well, the mail was quite long already, and the issue-tracker issue was linked.
Things that were proposed:
* Use both -v and --version
This is very unusual. I don't know of a single example other than existing argparse. Incompatible to existing optparse usage.
* Use both -V and --version
A very common combination; many programs which support --version accompany it with -V. However, if we'd add '-V' to the default option strings, we would likely break existing programs which worked around the so-far default.
* Use just --version
IMO the only way, and the way optparse does it.
* Print out just the version string * Print out program name with the version string
If this is an issue: With optparse, the version argument value is printed, which is often something like '%prog '+VERSION (for argparse, '%(prog)s '+VERSION or '%%(prog)s %s' % VERSION). This way, the decision is left to the programmer. Completely agreeable, as far as I'm concerned.
I put up a poll [...]
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 ...
A. Very. Bad. Idea.
... and redirect people to the more flexible addargument approach.
It is ok to /allow/ people to customize the flags to whatever they want. It is /not/ ok to /force/ them to do so, if there is a perfectly reasonable solution which allows them to stick with their habits. And there is one: drop the '-v' default. The only way (see above).
In the face of ambiguity, refuse the temptation to guess.
No guessing is needed (and the ZoP aphorism is not applicable here: this is not about guessing what the user might have meant. Besides, if the user specifies '--version', [s]he /very/ likely wants some info about the program version; giving '-v' can have been done looking forward to --verbose output (ok, nothing bad will happen, but it mismatches user expectations).
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.
A /very little/ bit. When fetching stdout to get the program version, it is much more reasonable to rely on '--version' than on '-v'. This is /the/ option string which is best supported by far.
But I'd really like a consensus about the correct behavior, and so far I have not seen that.
We'll have one ;-)
-- Tobias
- Previous message: [Python-Dev] Python 2.7b1 and argparse's version action
- Next message: [Python-Dev] Python 2.7b1 and argparse's version action
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]