diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2014-10-28 15:07:14 +0100 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2014-10-28 15:07:14 +0100 |
commit | 993c782565aed357f804ee559153f2ecaa84c383 (patch) | |
tree | 1a82095db4769b300c9189c82f1b59613c8479d1 | |
parent | 85f16bf5e52d180227e755edd4780383c60ecd9d (diff) | |
download | cpython-git-993c782565aed357f804ee559153f2ecaa84c383.tar.gz |
#22196: link to Enum in the nametuple documentation. Patch by Karmen Dykstra.
-rw-r--r-- | Doc/library/collections.rst | 7 | ||||
-rw-r--r-- | Misc/ACKS | 1 |
2 files changed, 5 insertions, 3 deletions
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 <http://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/>`_ @@ -361,6 +361,7 @@ Virgil Dupras Bruno Dupuis Andy Dustman Gary Duzan +Karmen Dykstra Eugene Dvurechenski Josip Dzolonga Maxim Dzumanenko |