Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54924df

Browse files
committed
improve Enum docs
1 parent 97be87a commit 54924df

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

Doc/library/enum.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ The next variation of :class:`Enum` provided, :class:`IntFlag`, is also based
542542
on :class:`int`. The difference being :class:`IntFlag` members can be combined
543543
using the bitwise operators (&, \|, ^, ~) and the result is still an
544544
:class:`IntFlag` member. However, as the name implies, :class:`IntFlag`
545-
members also subclass :class:`int` and can be used wherever an :class:`int` is.
546-
Any operation on an :class:`IntFlag` member besides the bit-wise operations
547-
will lose the :class:`IntFlag` membership.
545+
members also subclass :class:`int` and can be used wherever an :class:`int` is
546+
used. Any operation on an :class:`IntFlag` member besides the bit-wise
547+
operations will lose the :class:`IntFlag` membership.
548548

549549
.. versionadded:: 3.6
550550

@@ -955,10 +955,11 @@ and raise an error if the two do not match::
955955
``Enum`` member type
956956
""""""""""""""""""""
957957

958-
:class:`Enum` members are instances of an :class:`Enum` class, and even
959-
though they are accessible as `EnumClass.member`, they should not be accessed
960-
directly from the member as that lookup may fail or, worse, return something
961-
besides the ``Enum`` member you looking for::
958+
:class:`Enum` members are instances of their :class:`Enum` class, and are
959+
normally accessed as ``EnumClass.member``. Under certain circumstances they
960+
can also be accessed as ``EnumClass.member.member``, but you should never do
961+
this as that lookup may fail or, worse, return something besides the
962+
:class:`Enum` member you are looking for::
962963

963964
>>> class FieldTypes(Enum):
964965
... name = 0
@@ -976,16 +977,16 @@ besides the ``Enum`` member you looking for::
976977
Boolean value of ``Enum`` classes and members
977978
"""""""""""""""""""""""""""""""""""""""""""""
978979

979-
``Enum`` members that are mixed with non-Enum types (such as
980+
:class:`Enum` members that are mixed with non-:class:`Enum` types (such as
980981
:class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in
981-
type's rules; otherwise, all members evaluate as :data:`True`. To make your own
982-
Enum's boolean evaluation depend on the member's value add the following to
982+
type's rules; otherwise, all members evaluate as :data:`True`. To make your
983+
own Enum's boolean evaluation depend on the member's value add the following to
983984
your class::
984985

985986
def __bool__(self):
986987
return bool(self.value)
987988

988-
``Enum`` classes always evaluate as :data:`True`.
989+
:class:`Enum` classes always evaluate as :data:`True`.
989990

990991

991992
``Enum`` classes with methods

0 commit comments

Comments
 (0)