]> granicus.if.org Git - python/commitdiff
#22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra.
authorEzio Melotti <ezio.melotti@gmail.com>
Tue, 28 Oct 2014 14:07:14 +0000 (15:07 +0100)
committerEzio Melotti <ezio.melotti@gmail.com>
Tue, 28 Oct 2014 14:07:14 +0000 (15:07 +0100)
Doc/library/collections.rst
Misc/ACKS

index 3ec32407951de147cdb1236950e0c61efee4e250..1614758f0212ec56a48986d68b0870508328cb60 100644 (file)
@@ -908,13 +908,14 @@ customize a prototype instance:
     >>> 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/>`_
index 00ef5e38ad954ca6fa5f7f2083a0e1be2ac282ee..0bdaab6266b6bc0b7ab7b585ed87385862f3b3a0 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -361,6 +361,7 @@ Virgil Dupras
 Bruno Dupuis
 Andy Dustman
 Gary Duzan
+Karmen Dykstra
 Eugene Dvurechenski
 Josip Dzolonga
 Maxim Dzumanenko