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


Groups > comp.lang.python > #83216 > unrolled thread

Argparse defaults

Started by"Joseph L. Casale" <jcasale@activenetwerx.com>
First post2015-01-04 17:58 +0000
Last post2015-01-04 17:58 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#83216 — Argparse defaults

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2015-01-04 17:58 +0000
SubjectArgparse defaults
Message-ID<mailman.17379.1420394408.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web