[docs] enum docs outdated re attribute access (issue 25594)

ghost.adh at gmail.com ghost.adh at gmail.com
Fri Nov 13 13:25:34 EST 2015


Reviewers: ,

Message:
One typo.


https://bugs.python.org/review/25594/diff/15947/Doc/library/enum.rst
File Doc/library/enum.rst (right):

https://bugs.python.org/review/25594/diff/15947/Doc/library/enum.rst#newcode733
Doc/library/enum.rst:733: Enum members are instances of an Enum class,
and even though they are
Not related to the issue, but perhaps one of the Enum could be linked
with :class:`Enum`?

https://bugs.python.org/review/25594/diff/15947/Doc/library/enum.rst#newcode747
Doc/library/enum.rst:747: The :attr:`__members__` attribtute is only
available on the class.
Should read "attribute"



Please review this at https://bugs.python.org/review/25594/

Affected files:
  Doc/library/enum.rst


diff -r 828c9b920532 Doc/library/enum.rst
--- a/Doc/library/enum.rst	Fri Nov 13 15:18:26 2015 +0200
+++ b/Doc/library/enum.rst	Fri Nov 13 10:17:02 2015 -0800
@@ -724,31 +724,34 @@ The most interesting thing about Enum me
 :class:`EnumMeta` creates them all while it is creating the :class:`Enum`
 class itself, and then puts a custom :meth:`__new__` in place to ensure
 that no new ones are ever instantiated by returning only the existing
 member instances.
 
 
 Finer Points
 ^^^^^^^^^^^^
 
 Enum members are instances of an Enum class, and even though they are
-accessible as `EnumClass.member`, they are not accessible directly from
+accessible as `EnumClass.member`, they may not be accessible directly from
 the member::
 
-    >>> Color.red
-    <Color.red: 1>
-    >>> Color.red.blue
-    Traceback (most recent call last):
+    >>> class FieldTypes(Enum):
+    ...     name = 0
+    ...     value = 1
+    ...     size = 2
     ...
-    AttributeError: 'Color' object has no attribute 'blue'
+    >>> FieldTypes.value.size
+    <FieldTypes.size: 2>
+    >>> FieldTypes.size.value
+    2
 
-Likewise, the :attr:`__members__` is only available on the class.
+The :attr:`__members__` attribtute is only available on the class.
 
 If you give your :class:`Enum` subclass extra methods, like the `Planet`_
 class above, those methods will show up in a :func:`dir` of the member,
 but not of the class::
 
     >>> dir(Planet)
     ['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__members__', '__module__']
     >>> dir(Planet.EARTH)
     ['__class__', '__doc__', '__module__', 'name', 'surface_gravity', 'value']
 




More information about the docs mailing list