Closed
Description
Documentation
Quoting Doc/howto/enum.rst:1148
:
- names of pseudo-flags are constructed from their members' names::
>>> (Color.RED | Color.GREEN).name
'RED|GREEN'
This section was originally added in 7aaeb2a3.
If you have a zero-valued flag, and you didn't explicitly give it a name, this doesn't seem to apply, it returns None
instead.
class NoZero(Flag):
ONE = 1
class HasZero(Flag):
ZERO = 0
ONE = 1
print(NoZero(0).name, type(NoZero(0).name)) # None <class 'NoneType'>
print(HasZero(0).name, type(HasZero(0).name)) # ZERO <class 'str'>
I'm not entirely sure if this should be considered a documentation issue or a bug report (or both). It doesn't really feel like zero should be treated any differently from other unnamed combinations. But at the same time, I've tested, and this is already the existing behavior in 3.10 through 3.12, and it doesn't seem to be documented anywhere.