FAQ
Hi, all,

I notice that Python 2.7 beta 1 now contains the argparse module, which
might be a good thing. The code has been cleaned up, too.

But there is still one issue with argparse:
Completely unnecessarily, the 'version' constructor argument is now
deprecated. This fact doesn't solve any problem I can think of; the
only effect is to make programming more cumbersome, and it is /one more/
difference to optparse.

The 'version' argument is a perfectly reasonable way to provide a script
with a simple version information feature. Of course, it should only
define the '--version' argument; it *must not* define '-v' for this
purpose, since this is commonly used for verbosity. I have lots of
scripts which use optparse, and every single one uses the version
argument. I consider this a matter of good style.

Of course, if a more fancy version information is needed, it is
perfectly possible to just omit the version argument during creation
and build a special 'version' action, e.g. reporting the versions of all
imported modules. No deprecation warnings are needed for this.

*Before Python 2.7 getting a production release*, 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.

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.
This is how the vast majority of *x tools looks like.
(well, some use '-h' for something like "host" or "human readable";
but just a few strange misfits use -v instead of -V for the version.)
No reason to change this behaviour.

What do you think?

--
Cheers,

Tobias

Search Discussions

  • Chris Rebert at Apr 18, 2010 at 2:09 am

    On Sat, Apr 17, 2010 at 6:53 PM, Tobias Herp wrote:
    Hi, all,

    I notice that Python 2.7 beta 1 now contains the argparse module, which
    might be a good thing. ?The code has been cleaned up, too.

    But there is still one issue with argparse:
    Completely unnecessarily, the 'version' constructor argument is now
    deprecated. ?This fact doesn't solve any problem I can think of; the
    only effect is to make programming more cumbersome, and it is /one more/
    difference to optparse. <snip>
    *Before Python 2.7 getting a production release*, 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.

    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.
    This is how the vast majority of *x tools looks like.
    ?(well, some use '-h' for something like "host" or "human readable";
    ?but just a few strange misfits use -v instead of -V for the version.)
    No reason to change this behaviour.

    What do you think?
    You'd probably ought to just complain upstream to the argparse project
    itself. The change doesn't seem to have been made specifically for std
    lib inclusion (though I didn't read the bug in depth).

    This looks like the relevant issue:
    http://code.google.com/p/argparse/issues/detail?idC

    Relevant revision:
    http://code.google.com/p/argparse/source/detail?r�

    Cheers,
    Chris
  • Tobias Herp at Apr 18, 2010 at 2:44 am

    Am 18.04.2010 04:09, schrieb Chris Rebert:
    On Sat, Apr 17, 2010 at 6:53 PM, Tobias Herp
    wrote:
    Hi, all,

    I notice that Python 2.7 beta 1 now contains the argparse module, which
    might be a good thing. The code has been cleaned up, too.

    But there is still one issue with argparse:
    Completely unnecessarily, the 'version' constructor argument is now
    deprecated. This fact doesn't solve any problem I can think of; the
    only effect is to make programming more cumbersome, and it is /one more/
    difference to optparse. <snip>
    *Before Python 2.7 getting a production release*, 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.

    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.
    This is how the vast majority of *x tools looks like.
    (well, some use '-h' for something like "host" or "human readable";
    but just a few strange misfits use -v instead of -V for the version.)
    No reason to change this behaviour.

    What do you think?
    You'd probably ought to just complain upstream to the argparse project
    itself. The change doesn't seem to have been made specifically for std
    lib inclusion (though I didn't read the bug in depth).

    This looks like the relevant issue:
    http://code.google.com/p/argparse/issues/detail?idC
    Yes, this is the issue I once submitted. I had a very hard time
    discussing, since Steven insisted (and apparently still insists) in -v
    as a reasonable default short option for the version feature.

    Then I had some password database problems, and during the time I fell
    silent, he decided to deprecate the version argument.

    Since the code has been cleaned up and differs in many details from the
    current argparse v1.1, I hoped for somebody with a Python hat on to say,
    "This module is nice, but to make it in a production release of Python
    these simple issues must be fixed."

    To plagiarise Galahad (Monty Python and the Holy Grail):
    "Is there someone else up there we could talk to?"

    --
    Tobias
  • Martin v. Loewis at Apr 18, 2010 at 7:31 am
    What do you think?
    If you want something to happen, you need to bring this up on python-dev.

    Regards,
    Martin

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 18, '10 at 1:53a
activeApr 18, '10 at 7:31a
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase