
On 2021-08-30 09:23, Chris Angelico wrote:
On Tue, Aug 31, 2021 at 2:19 AM Christopher Barker <pythonchb@gmail.com> wrote:
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.
In general I find that harder to grok than just using separate boolean arguments for each flag. -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown