mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -656,6 +656,13 @@ be combined with them::
|
|||
>>> Perm.X | 8
|
||||
<Perm.8|X: 9>
|
||||
|
||||
:class:`IntFlag` members can also be iterated over::
|
||||
|
||||
>>> list(RW)
|
||||
[<Perm.R: 4>, <Perm.W: 2>]
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
|
||||
Flag
|
||||
^^^^
|
||||
|
@ -709,6 +716,14 @@ value::
|
|||
>>> bool(Color.BLACK)
|
||||
False
|
||||
|
||||
:class:`Flag` members can also be iterated over::
|
||||
|
||||
>>> purple = Color.RED | Color.BLUE
|
||||
>>> list(purple)
|
||||
[<Color.BLUE: 2>, <Color.RED: 1>]
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
.. note::
|
||||
|
||||
For the majority of new code, :class:`Enum` and :class:`Flag` are strongly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue