From: Ezio Melotti Date: Tue, 28 Oct 2014 14:07:14 +0000 (+0100) Subject: #22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra. X-Git-Tag: v3.5.0a1~607 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=993c782565aed357f804ee559153f2ecaa84c383;p=python #22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra. --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 3ec3240795..1614758f02 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -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 `_ diff --git a/Misc/ACKS b/Misc/ACKS index 00ef5e38ad..0bdaab6266 100644 --- 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