

3·
1 day agowhile many great things have been said in this thread i’ll also link to the docs for enum.Flag
(docs.python.org) which wraps bitmap integer enums
nya !!! :3333 gay uwu
I’m in a bad place rn so if I’m getting into an argument please tell me to disconnect for a bit as I dont deal with shit like that well :3
while many great things have been said in this thread i’ll also link to the docs for enum.Flag
(docs.python.org) which wraps bitmap integer enums
one small gripe i have is that the repr¹ doesn’t handle aliases (ie items with more than one bit set) that well , but tbh its not an easy problem
example to illustrate the problem :
class Foo(enum.Flag): A = auto() B = auto() C = auto() # no D AB = 0b0011 CD = 0b1100 print(Foo.AB | Foo.C) # <Foo.A|B|C: 7> NOT <Foo.AB|C: 7> print(Foo.CD | Foo.A) # <Foo.A|C|CD: 13> NOT <Foo.A|CD: 7>
its a minor thing but it annoys me a bit
[1]: the
_name_
member , which is used by__repr__
, of an enum member is actually generated either when the individual enum class is created or when the value is first needed by_missing_
. also the docs call these names surrounded by single underscores “sunder” names