mirror of
https://github.com/python/cpython.git
synced 2025-11-19 02:39:15 +00:00
issue23591: more docs; slight change to repr
This commit is contained in:
parent
bce9cbaf98
commit
27682d2698
3 changed files with 23 additions and 15 deletions
|
|
@ -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::
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue