Message371812
It is currently not obvious, reading :mod:`argparse` documentation, that :meth:`argparse.ArgumentParser.add_argument` could accept as 'choices' parameter an :class:`enum.Enum`.
However, it seems (at least to me) that this 'choices' parameter [1] is the perfect candidat of enums usage (see [2]).
So I suggest here to explicitly mention and illustrate such usage in current Python documentation. As far I as could test, such usage works at least with Python 3.5, 3.7, and 3.8.
A small patch on 'master' branches is in progress, and should shortly be available as a GitHub pull-request.
[1] https://docs.python.org/3/library/argparse.html#choices
[2] PEP 435: https://www.python.org/dev/peps/pep-0435/#motivation |
|
Date |
User |
Action |
Args |
2020-06-18 14:02:28 | vincent-ferotin | set | recipients:
+ vincent-ferotin, docs@python |
2020-06-18 14:02:27 | vincent-ferotin | set | messageid: <1592488947.97.0.69594351568.issue41024@roundup.psfhosted.org> |
2020-06-18 14:02:27 | vincent-ferotin | link | issue41024 messages |
2020-06-18 14:02:27 | vincent-ferotin | create | |
|