mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Enum: make Flag
and IntFlag
members iterable (GH-22221)
This commit is contained in:
parent
fc23a9483e
commit
7219e27087
4 changed files with 32 additions and 0 deletions
|
@ -753,6 +753,10 @@ class Flag(Enum):
|
|||
type(other).__qualname__, self.__class__.__qualname__))
|
||||
return other._value_ & self._value_ == other._value_
|
||||
|
||||
def __iter__(self):
|
||||
members, extra_flags = _decompose(self.__class__, self.value)
|
||||
return (m for m in members if m._value_ != 0)
|
||||
|
||||
def __repr__(self):
|
||||
cls = self.__class__
|
||||
if self._name_ is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue