
On Tue, Aug 31, 2021 at 11:47 AM Steven D'Aprano <steve@pearwood.info> wrote:
On Tue, Aug 31, 2021 at 02:23:29AM +1000, Chris Angelico wrote:
On Tue, Aug 31, 2021 at 2:19 AM Christopher Barker <pythonchb@gmail.com> wrote:
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.
I'm not a big user of Enums, but I *think* that only applies for IntEnums?
In any case, in this case it wouldn't make sense to combine NAN policies. What would it mean to combine the "raise exception on NAN" and "ignore NANs" policies?
Agreed. In this case, an enum offers little that a string can't do just as well. But there are plenty of other situations where an enum would be better (*ahem* open modes?), although they do come with a performance hit in some cases. ChrisA