Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83216

Argparse defaults

From "Joseph L. Casale" <jcasale@activenetwerx.com>
Subject Argparse defaults
Date 2015-01-04 17:58 +0000
Newsgroups comp.lang.python
Message-ID <mailman.17379.1420394408.18130.python-list@python.org> (permalink)

Show all headers | View raw


Does a facility exist to add an argument with a default being a function
that leverages the final parsed Namespace?

For example:

    group  = parser.add_argument_group(' some_group ')
    group.add_argument(
        '--some_group',
        nargs='*',
        type=str
    )
    group.add_argument(
        '-- some_group_def',
        default=func
    )

    args = parser.parse_args()

where func returns a value 'a' if args.some_group or 'b' otherwise?

Obviously I can break that out after but I am curious if the facility exists?

Thanks,
jlc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Argparse defaults "Joseph L. Casale" <jcasale@activenetwerx.com> - 2015-01-04 17:58 +0000

csiph-web