summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2020-09-16 20:01:00 (GMT)
committerGitHub <noreply@github.com>2020-09-16 20:01:00 (GMT)
commit7219e27087baaa8a5693b5bef1b1357bddbffa53 (patch)
tree9235d51826e2a14c26220a63a536085615604d16 /Doc/library/enum.rst
parentfc23a9483ef0d7c98bea9f82392377d0b6ef7b18 (diff)
downloadcpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.zip
cpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.tar.gz
cpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.tar.bz2
Enum: make `Flag` and `IntFlag` members iterable (GH-22221)
Diffstat (limited to 'Doc/library/enum.rst')
-rw-r--r--Doc/library/enum.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 32e8bbf..2f84be2 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -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