New submission from vincent-ferotin <vinc...@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@python components: Documentation messages: 371812 nosy: Vincent Férotin, docs@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 <rep...@bugs.python.org> <https://bugs.python.org/issue41024> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com