[New-bugs-announce] [issue41024] doc: Explicitly mention use of 'enum.Enum' as a valid container for 'choices' argument of 'argparse.ArgumentParser.add_argument'

vincent-ferotin report at bugs.python.org
Thu Jun 18 10:02:27 EDT 2020


New submission from vincent-ferotin <vincent at vincent-ferotin.info>:

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

----------
assignee: docs at python
components: Documentation
messages: 371812
nosy: Vincent Férotin, docs at python
priority: normal
severity: normal
status: open
title: doc: Explicitly mention use of 'enum.Enum' as a valid container for 'choices' argument of 'argparse.ArgumentParser.add_argument'
type: enhancement
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41024>
_______________________________________


More information about the New-bugs-announce mailing list