On Tue, Aug 31, 2021 at 2:19 AM Christopher Barker <python...@gmail.com> wrote: > > On Mon, Aug 30, 2021 at 12:57 AM Ronald Oussoren <ronaldousso...@mac.com> > wrote: > > On 28 Aug 2021, at 07:14, Christopher Barker <python...@gmail.com> wrote: >>> >>> >> Also +1 on a string flag, rather than an Enum. >> >> ou prefer strings for the options rather than an Enum? The enum clearly >> documents what the valid options are for the option. > > > So does documentation (docstrings, useful error messages). I don't think the > documentation built in to an Enum is any easier to access. In fact, looking > now, I'm trying to see how an Enum provides any easy to access documentation > -- other than looking at the creation code. As a rule, I don't think Enums > provide documentation of the valid values, but rather, enforcement. > > e.g.: what are the valid values? what do they mean? > > To be honest, I haven't really used Enums much (in fact, only to mirror C > enums in extension code), but part of that is because I have yet to see what > the point is in Python, over simple string flags. > > I suppose they provide a real advantage for static typing, but other than > that I just don't see it.
They provide a *huge* advantage when they can be combined. It's easy to accept a flags argument that is the bitwise Or of a collection of flags, and then ascertain whether or not a specific flag was included. The repr of such a combination is useful and readable, too. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WK4HWQIKMGBDSHRAE43D562WQBCDP23E/ Code of Conduct: http://python.org/psf/codeofconduct/