summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/enum.rst')
-rw-r--r--Doc/library/enum.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index eb8b94b..87aa8b1 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -674,6 +674,8 @@ while combinations of flags won't::
... green = auto()
... white = red | blue | green
...
+ >>> Color.white
+ <Color.white: 7>
Giving a name to the "no flags set" condition does not change its boolean
value::
@@ -1068,3 +1070,23 @@ but not of the class::
>>> dir(Planet.EARTH)
['__class__', '__doc__', '__module__', 'name', 'surface_gravity', 'value']
+
+Combining members of ``Flag``
+"""""""""""""""""""""""""""""
+
+If a combination of Flag members is not named, the :func:`repr` will include
+all named flags and all named combinations of flags that are in the value::
+
+ >>> class Color(Flag):
+ ... red = auto()
+ ... green = auto()
+ ... blue = auto()
+ ... magenta = red | blue
+ ... yellow = red | green
+ ... cyan = green | blue
+ ...
+ >>> Color(3) # named combination
+ <Color.yellow: 3>
+ >>> Color(7) # not named combination
+ <Color.cyan|magenta|blue|yellow|green|red: 7>
+