Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83216 > unrolled thread
| Started by | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| First post | 2015-01-04 17:58 +0000 |
| Last post | 2015-01-04 17:58 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Argparse defaults "Joseph L. Casale" <jcasale@activenetwerx.com> - 2015-01-04 17:58 +0000
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Date | 2015-01-04 17:58 +0000 |
| Subject | Argparse 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
Back to top | Article view | comp.lang.python
csiph-web