Skip to content

Commit b49c2e6

Browse files
committed
#22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra.
1 parent f2aac84 commit b49c2e6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Doc/library/collections.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,13 +908,14 @@ customize a prototype instance:
908908
>>> janes_account = default_account._replace(owner='Jane')
909909

910910
Enumerated constants can be implemented with named tuples, but it is simpler
911-
and more efficient to use a simple class declaration:
911+
and more efficient to use a simple :class:`~enum.Enum` :
912912

913913
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
914914
>>> Status.open, Status.pending, Status.closed
915915
(0, 1, 2)
916-
>>> class Status:
917-
open, pending, closed = range(3)
916+
>>> from enum import Enum
917+
>>> class Status(Enum):
918+
... open, pending, closed = range(3)
918919

919920
* `Recipe for named tuple abstract base class with a metaclass mix-in
920921
<http://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/>`_

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ Virgil Dupras
361361
Bruno Dupuis
362362
Andy Dustman
363363
Gary Duzan
364+
Karmen Dykstra
364365
Eugene Dvurechenski
365366
Josip Dzolonga
366367
Maxim Dzumanenko

0 commit comments

Comments
 (0)