This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vincent-ferotin
Recipients docs@python, vincent-ferotin
Date 2020-06-18.14:02:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592488947.97.0.69594351568.issue41024@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2020-06-18 14:02:28vincent-ferotinsetrecipients: + vincent-ferotin, docs@python
2020-06-18 14:02:27vincent-ferotinsetmessageid: <1592488947.97.0.69594351568.issue41024@roundup.psfhosted.org>
2020-06-18 14:02:27vincent-ferotinlinkissue41024 messages
2020-06-18 14:02:27vincent-ferotincreate