FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] gh-139487: add missing imports for standalone doctest `Enum` examples (GH-139488) by miss-islington · Pull Request #139493 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 6 additions & 2 deletions Doc/library/enum.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Loading

Back | FazBrowse Home | New Git URL