mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
merge
This commit is contained in:
commit
5bfb9f0b1f
1 changed files with 0 additions and 10 deletions
|
@ -942,16 +942,6 @@ customize a prototype instance:
|
||||||
>>> johns_account = default_account._replace(owner='John')
|
>>> johns_account = default_account._replace(owner='John')
|
||||||
>>> janes_account = default_account._replace(owner='Jane')
|
>>> 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:`~enum.Enum`:
|
|
||||||
|
|
||||||
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
|
|
||||||
>>> Status.open, Status.pending, Status.closed
|
|
||||||
(0, 1, 2)
|
|
||||||
>>> from enum import Enum
|
|
||||||
>>> class Status(Enum):
|
|
||||||
... open, pending, closed = range(3)
|
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue