[Python-checkins] cpython (3.4): #22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra.

ezio.melotti python-checkins at python.org
Tue Oct 28 15:17:06 CET 2014


https://hg.python.org/cpython/rev/701529f8ca93
changeset:   93183:701529f8ca93
branch:      3.4
parent:      93180:2f697bcc8f86
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Tue Oct 28 15:07:14 2014 +0100
summary:
  #22196: link to Enum in the nametuple documentation.  Patch by Karmen Dykstra.

files:
  Doc/library/collections.rst |  7 ++++---
  Misc/ACKS                   |  1 +
  2 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -908,13 +908,14 @@
     >>> janes_account = default_account._replace(owner='Jane')
 
 Enumerated constants can be implemented with named tuples, but it is simpler
-and more efficient to use a simple class declaration:
+and more efficient to use a simple :class:`~enum.Enum` :
 
     >>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
     >>> Status.open, Status.pending, Status.closed
     (0, 1, 2)
-    >>> class Status:
-        open, pending, closed = range(3)
+    >>> from enum import Enum
+    >>> class Status(Enum):
+    ...     open, pending, closed = range(3)
 
     * `Recipe for named tuple abstract base class with a metaclass mix-in
       <http://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/>`_
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -359,6 +359,7 @@
 Bruno Dupuis
 Andy Dustman
 Gary Duzan
+Karmen Dykstra
 Eugene Dvurechenski
 Josip Dzolonga
 Maxim Dzumanenko

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list