mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-139487: add missing imports for standalone doctest Enum examples (#139488)
This commit is contained in:
parent
75b1afe562
commit
f3d7faeafa
1 changed files with 6 additions and 2 deletions
|
|
@ -315,6 +315,7 @@ Data Types
|
|||
Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and
|
||||
any public methods defined on *self.__class__*::
|
||||
|
||||
>>> from enum import Enum
|
||||
>>> from datetime import date
|
||||
>>> class Weekday(Enum):
|
||||
... MONDAY = 1
|
||||
|
|
@ -341,7 +342,7 @@ Data Types
|
|||
A *staticmethod* that is used to determine the next value returned by
|
||||
:class:`auto`::
|
||||
|
||||
>>> from enum import auto
|
||||
>>> from enum import auto, Enum
|
||||
>>> class PowersOfThree(Enum):
|
||||
... @staticmethod
|
||||
... def _generate_next_value_(name, start, count, last_values):
|
||||
|
|
@ -373,7 +374,7 @@ Data Types
|
|||
A *classmethod* for looking up values not found in *cls*. By default it
|
||||
does nothing, but can be overridden to implement custom search behavior::
|
||||
|
||||
>>> from enum import StrEnum
|
||||
>>> from enum import auto, StrEnum
|
||||
>>> class Build(StrEnum):
|
||||
... DEBUG = auto()
|
||||
... OPTIMIZED = auto()
|
||||
|
|
@ -412,6 +413,7 @@ Data Types
|
|||
Returns the string used for *repr()* calls. By default, returns the
|
||||
*Enum* name, member name, and value, but can be overridden::
|
||||
|
||||
>>> from enum import auto, Enum
|
||||
>>> class OtherStyle(Enum):
|
||||
... ALTERNATE = auto()
|
||||
... OTHER = auto()
|
||||
|
|
@ -428,6 +430,7 @@ Data Types
|
|||
Returns the string used for *str()* calls. By default, returns the
|
||||
*Enum* name and member name, but can be overridden::
|
||||
|
||||
>>> from enum import auto, Enum
|
||||
>>> class OtherStyle(Enum):
|
||||
... ALTERNATE = auto()
|
||||
... OTHER = auto()
|
||||
|
|
@ -443,6 +446,7 @@ Data Types
|
|||
Returns the string used for *format()* and *f-string* calls. By default,
|
||||
returns :meth:`__str__` return value, but can be overridden::
|
||||
|
||||
>>> from enum import auto, Enum
|
||||
>>> class OtherStyle(Enum):
|
||||
... ALTERNATE = auto()
|
||||
... OTHER = auto()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue