mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
bpo-40066: [Enum] update str() and format() output (GH-30582)
Undo rejected PEP-663 changes: - restore `repr()` to its 3.10 status - restore `str()` to its 3.10 status New changes: - `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result - zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'` - update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type - added `_numeric_repr_` to `Flag` to control display of unnamed values - enums without doc strings have a more comprehensive doc string added - `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
This commit is contained in:
parent
37eab55ac9
commit
acf7403f9b
14 changed files with 2085 additions and 2019 deletions
|
@ -155,6 +155,8 @@ class RegexFlag:
|
|||
# sre extensions (experimental, don't rely on these)
|
||||
TEMPLATE = T = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking
|
||||
DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation
|
||||
__str__ = object.__str__
|
||||
_numeric_repr_ = hex
|
||||
|
||||
# sre exception
|
||||
error = sre_compile.error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue