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

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


https://hg.python.org/cpython/rev/2e3521e79d93
changeset: 93182:2e3521e79d93
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
@@ -361,6 +361,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

AltStyle によって変換されたページ (->オリジナル) /