diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2016-09-04 18:39:01 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2016-09-04 18:39:01 (GMT) |
commit | 27682d2698cefb9edabffd14290123f439a84790 (patch) | |
tree | 18ad8bf4f94d4417bd2b3eaf4fbd27e0b89cb231 /Doc | |
parent | bce9cbaf98fa92718a4dfb7011f93aca3993b4d4 (diff) | |
download | cpython-27682d2698cefb9edabffd14290123f439a84790.zip cpython-27682d2698cefb9edabffd14290123f439a84790.tar.gz cpython-27682d2698cefb9edabffd14290123f439a84790.tar.bz2 |
issue23591: more docs; slight change to repr
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/enum.rst | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index 7a5bb5f..ffc85fe 100644 --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -574,7 +574,7 @@ It is also possible to name the combinations:: >>> Perm.RWX <Perm.RWX: 7> >>> ~Perm.RWX - <Perm.0: 0> + <Perm.-8: -8> Another important difference between :class:`IntFlag` and :class:`Enum` is that if no flags are set (the value is 0), its boolean evaluation is :data:`False`:: @@ -615,6 +615,17 @@ flags being set, the boolean evaluation is :data:`False`:: >>> bool(Color.red & Color.green) False +Individual flags should have values that are powers of two (1, 2, 4, 8, ...), +while combinations of flags won't:: + + >>> class Color(Flag): + ... red = 1 + ... blue = 2 + ... green = 4 + ... white = 7 + ... # or + ... # white = red | blue | green + Giving a name to the "no flags set" condition does not change its boolean value:: |