issue23591: more docs; slight change to repr

This commit is contained in:
Ethan Furman 2016-09-04 11:39:01 -07:00
parent bce9cbaf98
commit 27682d2698
3 changed files with 23 additions and 15 deletions

View file

@ -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::