File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -730,18 +730,24 @@ member instances.
730730Finer Points
731731^^^^^^^^^^^^
732732
733- Enum members are instances of an Enum class, and even though they are
734- accessible as `EnumClass.member `, they are not accessible directly from
735- the member::
736-
737- >>> Color.red
738- <Color.red: 1>
739- >>> Color.red.blue
740- Traceback (most recent call last):
733+ :class: `Enum ` members are instances of an :class: `Enum ` class, and even
734+ though they are accessible as `EnumClass.member `, they should not be accessed
735+ directly from the member as that lookup may fail or, worse, return something
736+ besides the :class: `Enum ` member you looking for::
737+
738+ >>> class FieldTypes(Enum):
739+ ... name = 0
740+ ... value = 1
741+ ... size = 2
741742 ...
742- AttributeError: 'Color' object has no attribute 'blue'
743+ >>> FieldTypes.value.size
744+ <FieldTypes.size: 2>
745+ >>> FieldTypes.size.value
746+ 2
747+
748+ .. versionchanged :: 3.5
743749
744- Likewise, the :attr: `__members__ ` is only available on the class.
750+ The :attr: `__members__ ` attribute is only available on the class.
745751
746752If you give your :class: `Enum ` subclass extra methods, like the `Planet `_
747753class above, those methods will show up in a :func: `dir ` of the member,
You can’t perform that action at this time.
0 commit comments