Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'argument': 0.05; 'args': 0.07; "'a'": 0.09; 'parsed': 0.09; "'b'": 0.16; 'exists?': 0.16; 'func': 0.16; 'namespace?': 0.16; 'received:172.18.0': 0.16; 'thanks,': 0.17; 'obviously': 0.18; 'function': 0.29; "skip:' 10": 0.31; 'facility': 0.31; 'but': 0.35; 'add': 0.35; 'curious': 0.36; 'charset:us-ascii': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:unknown': 0.61; 'break': 0.61; 'default': 0.69; 'leverages': 0.84 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=NGyScNxeuSl9kF2CawaUazurpsiUNiZ1TJmy53crUtI= c=1 sm=1 a=CRTDazI5n6YA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=g3mLq75WYuDrh3Lt0JSDww==:17 a=T12v5P1pCST5HvWLfGoA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.activenetwerx.com X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 From: "Joseph L. Casale" To: "'python-list@python.org'" Subject: Argparse defaults Thread-Topic: Argparse defaults Thread-Index: AdAoR2IQ+Fh4F8AdTjOrpC8k66l4Jw== Date: Sun, 4 Jan 2015 17:58:55 +0000 Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.18.0.200] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420394408 news.xs4all.nl 2870 [2001:888:2000:d::a6]:55638 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83216 Does a facility exist to add an argument with a default being a function that leverages the final parsed Namespace? For example: group =3D parser.add_argument_group(' some_group ') group.add_argument( '--some_group', nargs=3D'*', type=3Dstr ) group.add_argument( '-- some_group_def', default=3Dfunc ) args =3D 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 exist= s? Thanks, jlc