[Python-Dev] Python 2.7b1 and argparse's version action (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Apr 19 03:40:53 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 ]
Tobias Herp wrote:
Be careful. There have been other personal opinions, and there are very many *X programs which form a standard which should be followed, and this is a /very strong/ argument, IMO.
If the "version=" argument were to only provide "--version", how would you conveniently add a "-V" shorthand?
This is trivial with the add_argument approach, but less straightforward with a "version=" argument to the parser constructor.
People that want "-v" to mean verbosity in 2.x can also trivially pass "conflict_handler='resolve'" to override the implicitly created version shorthand.
Would it be more convenient if argparse had never deviated from the GNU and optparse command line conventions in this respect? Sure it would be. But given that it did, a 'version' action that makes it trivial to choose the details of your version flags is a decent alternative approach to a now-ambiguous version argument to the parser constructor (especially once the default help string for the option is added).
Note there are two changes I believe should be made to the argparse documentation for 2.7 though:
- the '--version' example should either not use a shorthand, or should use the conventional '-V'
- this issue needs to be mentioned in the section on migrating from optparse.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- 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 ]